From b68b1d724af2ef3380564b1cf396433bd8891dc4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 12 Mar 2025 19:28:54 +0700 Subject: [PATCH 01/46] Move IMatteryPlayer as well as shortcuts to player subpackage --- .../ru/dbotthepony/mc/otm/client/model/ExosuitModel.java | 2 +- .../java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java | 3 +-- .../mc/otm/mixin/MixinAbstractHurtingProjectile.java | 2 +- .../java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java | 2 +- .../ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java | 2 +- .../java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java | 4 +--- .../dbotthepony/mc/otm/android/AndroidResearchManager.kt | 3 +-- .../mc/otm/android/feature/EnderTeleporterFeature.kt | 3 +-- .../mc/otm/android/feature/LimbOverclockingFeature.kt | 2 +- .../mc/otm/block/entity/storage/ItemMonitorBlockEntity.kt | 2 +- .../mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt | 3 +-- .../mc/otm/block/entity/tech/AndroidStationBlockEntity.kt | 3 +-- .../dbotthepony/mc/otm/block/tech/AndroidStationBlock.kt | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt | 5 +---- .../ru/dbotthepony/mc/otm/capability/MatteryPlayer.kt | 1 + .../dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt | 2 +- .../ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt | 3 +-- .../ru/dbotthepony/mc/otm/client/ClientEventHandler.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt | 2 +- .../ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt | 2 +- .../mc/otm/client/render/blockentity/BlackHoleRenderer.kt | 2 +- .../ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt | 2 +- .../mc/otm/client/screen/panels/EntityRendererPanel.kt | 2 +- .../mc/otm/client/screen/tech/AndroidStationScreen.kt | 4 +--- .../ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt | 2 +- .../mc/otm/compat/vanilla/ExtendedInventoryHandler.kt | 2 +- .../mc/otm/data/condition/ChanceWithPlaytimeCondition.kt | 2 +- .../mc/otm/data/condition/HasExoPackCondition.kt | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt | 1 + .../mc/otm/item/consumables/EssenceCapsuleItem.kt | 3 +-- .../dbotthepony/mc/otm/item/consumables/HealPillItem.kt | 2 +- .../dbotthepony/mc/otm/item/consumables/NotNormalFood.kt | 3 +-- .../dbotthepony/mc/otm/item/consumables/NotNormalPill.kt | 2 +- .../ru/dbotthepony/mc/otm/item/consumables/PillItem.kt | 2 +- .../mc/otm/item/exopack/AbstractExopackSlotUpgradeItem.kt | 2 +- .../dbotthepony/mc/otm/item/exopack/ExopackProbeItem.kt | 2 +- .../dbotthepony/mc/otm/item/exopack/ExopackUpgradeItem.kt | 2 +- .../ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt | 4 +--- .../ru/dbotthepony/mc/otm/item/weapon/FallingSunItem.kt | 4 +--- src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 2 +- .../ru/dbotthepony/mc/otm/menu/decorative/PainterMenu.kt | 2 +- .../ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt | 2 +- .../ru/dbotthepony/mc/otm/network/AndroidPackets.kt | 2 +- .../ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt | 3 +-- .../ru/dbotthepony/mc/otm/network/MenuDataPacket.kt | 5 +---- src/main/kotlin/ru/dbotthepony/mc/otm/player/Ext.kt | 8 ++++++++ .../mc/otm/{capability => player}/IMatteryPlayer.kt | 4 +++- .../dbotthepony/mc/otm/server/command/AndroidCommand.kt | 2 +- .../dbotthepony/mc/otm/server/command/ExopackCommand.kt | 2 +- .../dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt | 2 +- .../mc/otm/triggers/MatteryInventoryChangeTrigger.kt | 3 +-- 51 files changed, 60 insertions(+), 72 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/player/Ext.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/{capability => player}/IMatteryPlayer.kt (69%) 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 5e4cc73db..74217e95d 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 @@ -20,7 +20,7 @@ import net.minecraft.client.renderer.entity.player.PlayerRenderer; import net.minecraft.resources.ResourceLocation; import net.neoforged.neoforge.client.event.RenderPlayerEvent; import ru.dbotthepony.mc.otm.OverdriveThatMatters; -import ru.dbotthepony.mc.otm.capability.IMatteryPlayer; +import ru.dbotthepony.mc.otm.player.IMatteryPlayer; import javax.annotation.Nonnull; import java.util.Set; 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 1033c82d5..2b00f3d4f 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java @@ -8,8 +8,7 @@ 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.IMatteryPlayer; -import ru.dbotthepony.mc.otm.capability.MatteryCapability; +import ru.dbotthepony.mc.otm.player.IMatteryPlayer; @Mixin(FoodData.class) public class FoodDataMixin { 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 75c813851..21f131c1b 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAbstractHurtingProjectile.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAbstractHurtingProjectile.java @@ -7,7 +7,7 @@ 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.IMatteryPlayer; +import ru.dbotthepony.mc.otm.player.IMatteryPlayer; import ru.dbotthepony.mc.otm.registry.game.MSoundEvents; @Mixin(AbstractHurtingProjectile.class) 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 96f65547a..570f2e64b 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java @@ -17,7 +17,7 @@ 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.IMatteryPlayer; +import ru.dbotthepony.mc.otm.player.IMatteryPlayer; import ru.dbotthepony.mc.otm.capability.MatteryPlayer; import java.util.function.Predicate; 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 74d61a685..5ddfd3c17 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java @@ -10,7 +10,7 @@ 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.IMatteryPlayer; +import ru.dbotthepony.mc.otm.player.IMatteryPlayer; import ru.dbotthepony.mc.otm.config.ServerConfig; import ru.dbotthepony.mc.otm.core.util.ExperienceUtilsKt; import ru.dbotthepony.mc.otm.registry.game.MItems; diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java index 9af92c461..69723ad77 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java @@ -3,18 +3,16 @@ package ru.dbotthepony.mc.otm.mixin; import com.mojang.authlib.GameProfile; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; 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.IMatteryPlayer; +import ru.dbotthepony.mc.otm.player.IMatteryPlayer; import ru.dbotthepony.mc.otm.capability.MatteryPlayer; import java.util.Objects; 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 c61ba9e47..673d400e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt @@ -23,8 +23,7 @@ import ru.dbotthepony.mc.otm.MINECRAFT_SERVER import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER import ru.dbotthepony.mc.otm.OverdriveThatMatters 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.player.matteryPlayer import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.core.fromJsonStrict import ru.dbotthepony.mc.otm.core.fromNetwork 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 7668a679d..e477f34ab 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 @@ -28,7 +28,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.capability.energy.extractEnergyExact -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons @@ -49,7 +49,6 @@ 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.core.random import ru.dbotthepony.mc.otm.milliTime import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures import ru.dbotthepony.mc.otm.triggers.EnderTeleporterFallDeathTrigger 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 e03452450..ff824723c 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 @@ -7,7 +7,7 @@ import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayer -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures 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 41f92f2e7..0d6a8f427 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 @@ -23,7 +23,7 @@ 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.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.render.IGUIRenderable 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/block/entity/tech/AndroidChargerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt index 59282a830..15e39b78b 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 @@ -14,10 +14,9 @@ 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.player.matteryPlayer import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid -import ru.dbotthepony.mc.otm.core.random import ru.dbotthepony.mc.otm.core.shuffle import ru.dbotthepony.mc.otm.menu.tech.AndroidChargerMenu import ru.dbotthepony.mc.otm.registry.game.MBlockEntities 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 11ef62a3d..4ce822966 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,11 +13,10 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState 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.player.matteryPlayer 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.random import ru.dbotthepony.mc.otm.core.shuffle import ru.dbotthepony.mc.otm.core.util.countingLazy import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu 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 3d24e4f0b..a2838cd97 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 @@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.block.MatteryBlock import ru.dbotthepony.mc.otm.block.addSimpleDescription import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.registry.game.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 d2ac47101..c6b6da26d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.capability import com.google.common.collect.Streams import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component -import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack import net.neoforged.neoforge.capabilities.Capabilities @@ -34,13 +33,11 @@ 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.util.formatFluidLevel +import ru.dbotthepony.mc.otm.player.matteryPlayer import java.util.stream.Stream private val LOGGER = LogManager.getLogger() -val Player.matteryPlayer: MatteryPlayer get() = (this as IMatteryPlayer).otmPlayer -val LivingEntity.matteryPlayer: MatteryPlayer? get() = (this as? IMatteryPlayer)?.otmPlayer - /** * Does a checked energy receive, calls [IMatteryEnergyStorage.receiveEnergyChecked] if possible */ diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayer.kt index 24a237b93..7da125e94 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayer.kt @@ -99,6 +99,7 @@ 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.player.matteryPlayer import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.game.MItems 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 e24de2183..2cb90d1a1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt @@ -9,7 +9,7 @@ import net.neoforged.neoforge.client.settings.KeyConflictContext import net.neoforged.neoforge.network.PacketDistributor 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.player.matteryPlayer import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.is3DContext 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 6deaaeba9..5b6b2065e 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 net.neoforged.neoforge.network.PacketDistributor 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.player.matteryPlayer import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.RenderGravity -import ru.dbotthepony.mc.otm.client.render.drawArc import ru.dbotthepony.kommons.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/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index 4c54ef97e..9aa643ba2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -20,7 +20,7 @@ import net.neoforged.neoforge.network.PacketDistributor import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.android.feature.JumpBoostFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayer -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.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 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 ddc917ee3..b5acdc508 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -26,7 +26,7 @@ import net.neoforged.neoforge.common.ItemAbilities import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.MatteryPlayer -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.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 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 14f601f8e..d5b7da71b 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 @@ -12,7 +12,7 @@ import net.minecraft.world.level.levelgen.XoroshiroRandomSource import net.minecraft.world.level.material.FogType import org.joml.Matrix4f import ru.dbotthepony.mc.otm.capability.MatteryPlayer -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.math.linearInterpolation import ru.dbotthepony.mc.otm.milliTime 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 3a7cc7bd4..fbbcdcc2e 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 @@ -15,7 +15,7 @@ import org.lwjgl.opengl.GL30 import ru.dbotthepony.mc.otm.core.TranslatableComponent 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.player.matteryPlayer import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.* 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 dac9e5539..23e70a863 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.neoforged.neoforge.common.NeoForge import org.lwjgl.opengl.GL11 import ru.dbotthepony.kommons.util.getValue import ru.dbotthepony.kommons.util.setValue -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.moveMousePosScaled import ru.dbotthepony.mc.otm.client.render.WidgetLocation 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 f065cc23d..62a2b0e2a 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 net.neoforged.neoforge.network.PacketDistributor import ru.dbotthepony.mc.otm.capability.MatteryPlayer -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer 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 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 08190ec3c..18586cca3 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,6 @@ 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.capability.MatteryPlayer -import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.client.CursorType import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft @@ -33,9 +32,8 @@ 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.kommons.math.RGBAColor -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.screen.panels.button.BooleanButtonPanel -import ru.dbotthepony.mc.otm.core.RandomSource2Generator import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu import ru.dbotthepony.mc.otm.network.AndroidResearchRequestPacket import java.util.* 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 1bf4ebf86..45b9341f9 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 @@ -12,7 +12,7 @@ import net.neoforged.fml.ModList import net.neoforged.fml.loading.FMLEnvironment import net.neoforged.neoforge.network.PacketDistributor import ru.dbotthepony.kommons.math.RGBAColor -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.render.MGUIGraphics 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/vanilla/ExtendedInventoryHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/ExtendedInventoryHandler.kt index e5bb727c2..dbd44d4bc 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 @@ -19,7 +19,7 @@ import net.neoforged.neoforge.network.handling.IPayloadContext import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.capability.MatteryPlayer -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot 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 c62eba451..4c2e4c0fe 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,7 @@ 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.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.data.get import ru.dbotthepony.mc.otm.registry.data.MLootItemConditions 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 691022fb0..dab5df1b3 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 @@ -5,7 +5,7 @@ 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 ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.data.get import ru.dbotthepony.mc.otm.registry.data.MLootItemConditions 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 d7b76d2a1..a4f9651b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt @@ -21,6 +21,7 @@ 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.player.matteryPlayer import ru.dbotthepony.mc.otm.registry.CapabilitiesRegisterListener import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.game.MDataComponentTypes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/EssenceCapsuleItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/EssenceCapsuleItem.kt index 1ae7e9fdd..df8008a1c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/EssenceCapsuleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/EssenceCapsuleItem.kt @@ -13,11 +13,10 @@ import net.minecraft.world.item.* import net.minecraft.world.item.alchemy.PotionContents 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.player.matteryPlayer 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.random import ru.dbotthepony.mc.otm.core.util.getLevelFromXp import ru.dbotthepony.mc.otm.item.MatteryItem import ru.dbotthepony.mc.otm.registry.game.MDataComponentTypes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/HealPillItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/HealPillItem.kt index 6af3533ab..85012551a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/HealPillItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/HealPillItem.kt @@ -11,7 +11,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Rarity import net.minecraft.world.item.UseAnim import net.minecraft.world.level.Level -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.item.MatteryItem diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/NotNormalFood.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/NotNormalFood.kt index e2e5a6819..130ecdfb0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/NotNormalFood.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/NotNormalFood.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.item.consumables import net.minecraft.ChatFormatting import net.minecraft.core.component.DataComponentMap import net.minecraft.network.chat.Component -import net.minecraft.network.chat.Style import net.minecraft.tags.TagKey import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResult @@ -18,7 +17,7 @@ import net.minecraft.world.item.UseAnim import net.minecraft.world.level.Level import net.minecraft.world.level.gameevent.GameEvent import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent.EntityInteract -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.isShiftDown 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/consumables/NotNormalPill.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/NotNormalPill.kt index ff22e177e..bba61327c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/NotNormalPill.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/NotNormalPill.kt @@ -8,7 +8,7 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.item.* import net.minecraft.world.level.Level import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.item.MatteryItem import ru.dbotthepony.mc.otm.registry.MDamageTypes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/PillItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/PillItem.kt index 07ecc6c3d..ae82e1f30 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/PillItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/PillItem.kt @@ -10,7 +10,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Rarity import net.minecraft.world.item.UseAnim import net.minecraft.world.level.Level -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.item.MatteryItem 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 176a77418..e9750cab0 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 @@ -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.config.ServerConfig -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.isExplosion 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 4be2ec216..975a54a39 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 @@ -11,7 +11,7 @@ import net.minecraft.world.item.* import net.minecraft.world.level.Level 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.player.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.registry.MDamageTypes 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 2bc925cc7..f2eff31c5 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 @@ -14,7 +14,7 @@ import net.minecraft.world.item.TooltipFlag import net.minecraft.world.item.UseAnim import net.minecraft.world.level.Level import ru.dbotthepony.mc.otm.capability.MatteryPlayer -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.runIfClient 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 881c3d745..bd42bfb5f 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 @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.item.weapon import net.minecraft.core.BlockPos -import net.minecraft.core.component.DataComponents import net.minecraft.tags.BlockTags import net.minecraft.world.entity.EquipmentSlotGroup import net.minecraft.world.entity.LivingEntity @@ -26,14 +25,13 @@ 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 -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.core.damageType 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.nextVariance -import ru.dbotthepony.mc.otm.core.random import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.item.MatteryItem import ru.dbotthepony.mc.otm.item.addSimpleDescription diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/FallingSunItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/FallingSunItem.kt index 23b40cd7d..c5ce968ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/FallingSunItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/FallingSunItem.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.item.weapon import net.minecraft.core.BlockPos -import net.minecraft.core.component.DataComponents import net.minecraft.tags.BlockTags import net.minecraft.world.entity.EquipmentSlotGroup import net.minecraft.world.entity.LivingEntity @@ -26,14 +25,13 @@ 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 -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.core.damageType 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.nextVariance -import ru.dbotthepony.mc.otm.core.random import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.item.MatteryItem import ru.dbotthepony.mc.otm.item.addSimpleDescription 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 4a65058ae..8a3711faa 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,7 @@ import ru.dbotthepony.kommons.util.getValue import ru.dbotthepony.kommons.util.setValue import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorSlots import ru.dbotthepony.mc.otm.compat.curios.curiosSlots import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot 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 027b7ed25..ba94a0e29 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 @@ -15,7 +15,7 @@ import ru.dbotthepony.kommons.util.ListenableDelegate import ru.dbotthepony.kommons.util.getValue import ru.dbotthepony.kommons.util.setValue import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.collect.SupplierMap 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 974fa4823..08c56b58b 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 @@ -9,7 +9,7 @@ import net.minecraft.world.item.ItemStack import net.neoforged.neoforge.capabilities.Capabilities import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryPlayer -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/AndroidPackets.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/AndroidPackets.kt index 2ac263b4c..68701227b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/AndroidPackets.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/AndroidPackets.kt @@ -16,7 +16,7 @@ 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.extractEnergyExact -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.MatteryGUI import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.GlitchRenderer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt index 0fb081906..4e928e4df 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt @@ -15,7 +15,7 @@ import org.apache.logging.log4j.LogManager import ru.dbotthepony.kommons.math.RGBAColor import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.capability.MatteryPlayer -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.container.set @@ -24,7 +24,6 @@ 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.random import ru.dbotthepony.mc.otm.core.position import ru.dbotthepony.mc.otm.core.readItem import ru.dbotthepony.mc.otm.core.writeItem diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuDataPacket.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuDataPacket.kt index f981e2442..7da35ccbb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuDataPacket.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuDataPacket.kt @@ -1,18 +1,15 @@ package ru.dbotthepony.mc.otm.network import it.unimi.dsi.fastutil.bytes.ByteArrayList -import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.codec.StreamCodec import net.minecraft.network.protocol.common.custom.CustomPacketPayload import net.neoforged.neoforge.network.handling.IPayloadContext import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu import ru.dbotthepony.mc.otm.menu.MatteryMenu -import java.io.ByteArrayInputStream class MenuDataPacket(val containerId: Int, val bytes: ByteArrayList) : CustomPacketPayload { fun write(buff: FriendlyByteBuf) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/Ext.kt new file mode 100644 index 000000000..2b2b7ec7c --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/Ext.kt @@ -0,0 +1,8 @@ +package ru.dbotthepony.mc.otm.player + +import net.minecraft.world.entity.LivingEntity +import net.minecraft.world.entity.player.Player +import ru.dbotthepony.mc.otm.capability.MatteryPlayer + +val Player.matteryPlayer: MatteryPlayer get() = (this as IMatteryPlayer).otmPlayer +val LivingEntity.matteryPlayer: MatteryPlayer? get() = (this as? IMatteryPlayer)?.otmPlayer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/IMatteryPlayer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/IMatteryPlayer.kt similarity index 69% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/IMatteryPlayer.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/IMatteryPlayer.kt index 890f6385f..1789eb4f8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/IMatteryPlayer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/IMatteryPlayer.kt @@ -1,4 +1,6 @@ -package ru.dbotthepony.mc.otm.capability +package ru.dbotthepony.mc.otm.player + +import ru.dbotthepony.mc.otm.capability.MatteryPlayer interface IMatteryPlayer { // since new capabilities dont get to live through getCapability calls by design diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/AndroidCommand.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/AndroidCommand.kt index 44a14eb34..f56e583a5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/AndroidCommand.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/AndroidCommand.kt @@ -6,7 +6,7 @@ import net.minecraft.world.entity.player.Player import net.neoforged.neoforge.event.RegisterCommandsEvent import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidResearchType -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer object AndroidCommand { fun register(event: RegisterCommandsEvent) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/ExopackCommand.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/ExopackCommand.kt index 943283326..b95f3e460 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/ExopackCommand.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/ExopackCommand.kt @@ -6,7 +6,7 @@ import net.minecraft.world.entity.player.Player import net.neoforged.neoforge.event.RegisterCommandsEvent import net.neoforged.neoforge.server.command.EnumArgument import ru.dbotthepony.mc.otm.capability.MatteryPlayer.UpgradeType -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer object ExopackCommand { fun register(event: RegisterCommandsEvent) { 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 e25fdc498..e7e4c8b38 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt @@ -12,7 +12,7 @@ import net.minecraft.world.entity.monster.ElderGuardian import net.neoforged.neoforge.event.entity.living.LivingDeathEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.capability.MatteryPlayer -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.data.codec.SingletonCodec import ru.dbotthepony.mc.otm.registry.MRegistry 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 841b2d276..9170b5d7f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.triggers -import com.google.gson.JsonObject import com.mojang.serialization.Codec import it.unimi.dsi.fastutil.objects.ObjectArrayList import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet @@ -15,7 +14,7 @@ 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.player.matteryPlayer import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.core.isNotEmpty From 05a081d9cbbc8829f4e72533fabe8cd968cf4f0f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 12 Mar 2025 19:33:20 +0700 Subject: [PATCH 02/46] Move MatteryPlayer to player subpackage --- .../dbotthepony/mc/otm/datagen/tags/TagsProvider.kt | 2 +- .../ru/dbotthepony/mc/otm/mixin/MixinInventory.java | 2 +- .../ru/dbotthepony/mc/otm/mixin/MixinMinecraft.java | 2 +- .../java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java | 2 +- .../ru/dbotthepony/mc/otm/OverdriveThatMatters.kt | 3 +-- .../mc/otm/android/AndroidActiveFeature.kt | 2 +- .../ru/dbotthepony/mc/otm/android/AndroidFeature.kt | 2 +- .../dbotthepony/mc/otm/android/AndroidFeatureType.kt | 2 +- .../ru/dbotthepony/mc/otm/android/AndroidResearch.kt | 2 +- .../mc/otm/android/AndroidSwitchableFeature.kt | 2 +- .../mc/otm/android/feature/AttackBoostFeature.kt | 2 +- .../mc/otm/android/feature/EnderTeleporterFeature.kt | 2 +- .../mc/otm/android/feature/ExtendedReachFeature.kt | 2 +- .../mc/otm/android/feature/FallDampenersFeature.kt | 2 +- .../mc/otm/android/feature/ItemMagnetFeature.kt | 2 +- .../mc/otm/android/feature/JumpBoostFeature.kt | 2 +- .../mc/otm/android/feature/LimbOverclockingFeature.kt | 2 +- .../mc/otm/android/feature/NanobotsArmorFeature.kt | 2 +- .../android/feature/NanobotsRegenerationFeature.kt | 2 +- .../mc/otm/android/feature/NightVisionFeature.kt | 2 +- .../mc/otm/android/feature/ShockwaveFeature.kt | 2 +- .../mc/otm/android/feature/StepAssistFeature.kt | 2 +- .../mc/otm/android/feature/SwimBoostersFeature.kt | 2 +- .../dbotthepony/mc/otm/client/ClientEventHandler.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt | 2 +- .../mc/otm/client/render/GlitchRenderer.kt | 2 +- .../otm/client/screen/panels/EntityRendererPanel.kt | 2 +- .../mc/otm/client/screen/tech/AndroidStationScreen.kt | 2 +- .../mc/otm/compat/vanilla/ExtendedInventoryHandler.kt | 2 +- .../mc/otm/item/exopack/ExopackUpgradeItem.kt | 2 +- .../dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt | 2 +- .../mc/otm/menu/tech/AndroidStationMenu.kt | 2 +- .../mc/otm/network/MatteryPlayerPackets.kt | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/player/Ext.kt | 1 - .../ru/dbotthepony/mc/otm/player/IMatteryPlayer.kt | 2 -- .../mc/otm/{capability => player}/MatteryPlayer.kt | 6 ++++-- .../ru/dbotthepony/mc/otm/registry/game/MItems.kt | 11 +++++++---- .../mc/otm/server/command/ExopackCommand.kt | 2 +- .../mc/otm/triggers/KillAsAndroidTrigger.kt | 2 +- 39 files changed, 46 insertions(+), 45 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/{capability => player}/MatteryPlayer.kt (99%) 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 e84eeee6d..a46d37997 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 @@ -19,7 +19,7 @@ import net.minecraft.world.level.block.Block import net.neoforged.neoforge.common.Tags import net.neoforged.neoforge.data.event.GatherDataEvent import net.neoforged.neoforge.registries.NeoForgeRegistries -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.datagen.DataGen import java.util.EnumMap 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 570f2e64b..c41ac462c 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java @@ -18,7 +18,7 @@ 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.player.IMatteryPlayer; -import ru.dbotthepony.mc.otm.capability.MatteryPlayer; +import ru.dbotthepony.mc.otm.player.MatteryPlayer; import java.util.function.Predicate; diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinMinecraft.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinMinecraft.java index 328460fa8..2f8f0c691 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinMinecraft.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinMinecraft.java @@ -6,7 +6,7 @@ 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.Redirect; -import ru.dbotthepony.mc.otm.capability.MatteryPlayer; +import ru.dbotthepony.mc.otm.player.MatteryPlayer; @Mixin(Minecraft.class) public class MixinMinecraft { diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java index 69723ad77..bcde0cf79 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java @@ -13,7 +13,7 @@ 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.player.IMatteryPlayer; -import ru.dbotthepony.mc.otm.capability.MatteryPlayer; +import ru.dbotthepony.mc.otm.player.MatteryPlayer; import java.util.Objects; diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt index b020f9548..d32ffc843 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt @@ -6,7 +6,6 @@ import net.neoforged.bus.api.EventPriority import net.neoforged.fml.common.Mod import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent -import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent import ru.dbotthepony.mc.otm.android.AndroidResearchDescription import ru.dbotthepony.mc.otm.android.AndroidResearchDescriptions import ru.dbotthepony.mc.otm.android.AndroidResearchManager @@ -15,7 +14,7 @@ import ru.dbotthepony.mc.otm.android.AndroidResearchResults import ru.dbotthepony.mc.otm.android.feature.EnderTeleporterFeature import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.drive.DrivePool import ru.dbotthepony.mc.otm.client.AndroidAbilityKeyMapping import ru.dbotthepony.mc.otm.client.AndroidMenuKeyMapping diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidActiveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidActiveFeature.kt index 0b18e6ebe..230a0cd47 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidActiveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidActiveFeature.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.android import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.Camera import net.neoforged.neoforge.client.event.RenderLevelStageEvent -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource abstract class AndroidActiveFeature(type: AndroidFeatureType<*>, android: MatteryPlayer) : AndroidSwitchableFeature(type, android) { 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 c781b64a4..958e2ae6f 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,7 @@ import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent import ru.dbotthepony.mc.otm.network.syncher.SynchableGroup import ru.dbotthepony.kommons.util.getValue import ru.dbotthepony.kommons.util.setValue -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.core.nbt.set abstract class AndroidFeature(val type: AndroidFeatureType<*>, val android: MatteryPlayer) : INBTSerializable { 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 43c6d78ca..d01adc685 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt @@ -4,7 +4,7 @@ import net.minecraft.network.chat.Component import net.minecraft.network.chat.ComponentContents import net.minecraft.network.chat.MutableComponent import net.minecraft.network.chat.contents.TranslatableContents -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.core.getKeyNullable import ru.dbotthepony.mc.otm.registry.MRegistry 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 68ebb9380..3954b9f2e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt @@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.network.syncher.SynchableGroup import ru.dbotthepony.kommons.util.getValue import ru.dbotthepony.kommons.util.setValue import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.awareItemsStream import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent 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 a5281e23c..df6ea10af 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 net.minecraft.server.level.ServerPlayer import ru.dbotthepony.kommons.math.RGBAColor import ru.dbotthepony.kommons.util.getValue import ru.dbotthepony.kommons.util.setValue -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.nbt.set 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 fce5bb5aa..d70658560 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 @@ -4,7 +4,7 @@ import net.minecraft.world.entity.ai.attributes.AttributeModifier import net.minecraft.world.entity.ai.attributes.Attributes import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidFeature -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures 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 e477f34ab..501c25147 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 ru.dbotthepony.kommons.math.RGBAColor 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.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource 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 abd8e66be..c816e044e 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 @@ -4,7 +4,7 @@ import net.minecraft.world.entity.ai.attributes.AttributeModifier import net.minecraft.world.entity.ai.attributes.Attributes import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidFeature -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures 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 817a13809..59e4e4d37 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,7 +3,7 @@ package ru.dbotthepony.mc.otm.android.feature import net.minecraft.server.level.ServerPlayer import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent import ru.dbotthepony.mc.otm.android.AndroidFeature -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.core.isFall import ru.dbotthepony.mc.otm.registry.game.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 984a61986..fd4627d00 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.kommons.math.RGBAColor import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft 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 4a3f5f195..b81c5b3c4 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 @@ -7,7 +7,7 @@ import ru.dbotthepony.kommons.math.RGBAColor import ru.dbotthepony.kommons.util.getValue import ru.dbotthepony.kommons.util.setValue import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons 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 ff824723c..061d5302e 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 @@ -6,7 +6,7 @@ import net.minecraft.world.entity.ai.attributes.Attributes import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidFeature -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures 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 de77734b9..d80ce2a14 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 net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent import ru.dbotthepony.kommons.util.getValue import ru.dbotthepony.kommons.util.setValue import ru.dbotthepony.mc.otm.android.AndroidFeature -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.core.isBypassArmor import ru.dbotthepony.mc.otm.core.math.Decimal 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 d5ffa71ff..d2edf3af3 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 @@ -7,7 +7,7 @@ import net.minecraft.world.level.GameRules import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.android.AndroidFeature -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures import ru.dbotthepony.mc.otm.registry.StatNames import ru.dbotthepony.mc.otm.core.nbt.set 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 23fde7109..d3b676b82 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 @@ -4,7 +4,7 @@ import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.effect.MobEffects import ru.dbotthepony.kommons.math.RGBAColor import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons 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 786ff4cdd..c38754b02 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,7 @@ import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.monster.warden.Warden import net.neoforged.neoforge.network.PacketDistributor import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons 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 7c324d52c..92d048b78 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 @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.android.feature import net.minecraft.world.entity.ai.attributes.AttributeModifier import net.minecraft.world.entity.ai.attributes.Attributes import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.kommons.math.RGBAColor 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 4816f104c..35b7d952b 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 @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.android.feature import net.minecraft.world.entity.ai.attributes.AttributeModifier import net.neoforged.neoforge.common.NeoForgeMod import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.config.AndroidConfig 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 9aa643ba2..fa0975202 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -19,7 +19,7 @@ import net.neoforged.neoforge.event.entity.player.ItemTooltipEvent import net.neoforged.neoforge.network.PacketDistributor import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.android.feature.JumpBoostFeature -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.player.matteryPlayer 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/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index b5acdc508..20e18e1c6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -25,7 +25,7 @@ import net.neoforged.neoforge.client.gui.VanillaGuiLayers import net.neoforged.neoforge.common.ItemAbilities import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.render.sprites.MatteryAtlas 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 d5b7da71b..de9cd3653 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 @@ -11,7 +11,7 @@ import net.minecraft.client.renderer.GameRenderer import net.minecraft.world.level.levelgen.XoroshiroRandomSource import net.minecraft.world.level.material.FogType import org.joml.Matrix4f -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.math.linearInterpolation 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 62a2b0e2a..9a3a55d20 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 @@ -6,7 +6,7 @@ import net.minecraft.client.gui.screens.inventory.InventoryScreen import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.player.Player import net.neoforged.neoforge.network.PacketDistributor -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.Widgets8 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 18586cca3..fee98d5b6 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 @@ -14,7 +14,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.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.client.CursorType import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft 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 dbd44d4bc..5393b66bf 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 @@ -18,7 +18,7 @@ import net.minecraft.world.item.Items import net.neoforged.neoforge.network.handling.IPayloadContext import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.menu.MatteryMenu 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 f2eff31c5..faf2b52ee 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 @@ -13,7 +13,7 @@ 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.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.player.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/menu/ExopackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt index 0d8e58e48..0eca65659 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt @@ -17,7 +17,7 @@ import net.minecraft.world.inventory.Slot import net.minecraft.world.inventory.TransientCraftingContainer import net.minecraft.world.item.ItemStack import net.neoforged.neoforge.network.PacketDistributor -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.compat.curios.curiosSlots import ru.dbotthepony.mc.otm.container.util.slotIterator import ru.dbotthepony.mc.otm.menu.input.InstantBooleanInput 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 08c56b58b..3878047bd 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 @@ -8,7 +8,7 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack import net.neoforged.neoforge.capabilities.Capabilities import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt index 4e928e4df..fbc7c2cb9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt @@ -14,7 +14,7 @@ import net.neoforged.neoforge.network.handling.IPayloadContext import org.apache.logging.log4j.LogManager import ru.dbotthepony.kommons.math.RGBAColor import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.container.get diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/Ext.kt index 2b2b7ec7c..579ec2cfb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/Ext.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.player import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.player.Player -import ru.dbotthepony.mc.otm.capability.MatteryPlayer val Player.matteryPlayer: MatteryPlayer get() = (this as IMatteryPlayer).otmPlayer val LivingEntity.matteryPlayer: MatteryPlayer? get() = (this as? IMatteryPlayer)?.otmPlayer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/IMatteryPlayer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/IMatteryPlayer.kt index 1789eb4f8..ea30100b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/IMatteryPlayer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/IMatteryPlayer.kt @@ -1,7 +1,5 @@ package ru.dbotthepony.mc.otm.player -import ru.dbotthepony.mc.otm.capability.MatteryPlayer - interface IMatteryPlayer { // since new capabilities dont get to live through getCapability calls by design // and data attachments are.... limited. diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayer.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt index 7da125e94..c69c2a785 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.capability +package ru.dbotthepony.mc.otm.player import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack @@ -68,11 +68,14 @@ 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.MachineJobEventLoop +import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade +import ru.dbotthepony.mc.otm.capability.energy 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.capability.receiveEnergy import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.config.ExopackConfig @@ -99,7 +102,6 @@ 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.player.matteryPlayer import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.game.MItems diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MItems.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MItems.kt index eacba6edc..c0bc06fe3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MItems.kt @@ -28,7 +28,7 @@ import net.minecraft.world.level.block.Block import net.neoforged.bus.api.IEventBus import net.neoforged.neoforge.common.SimpleTier import ru.dbotthepony.mc.otm.capability.ITieredUpgradeSet -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.config.CablesConfig import ru.dbotthepony.mc.otm.config.ItemsConfig @@ -637,9 +637,12 @@ object MItems { object ExopackUpgrades { 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(MatteryPlayer.UpgradeType.CRAFTING, "crafting_upgrade", "crafting_upgraded") } - val SMELTING_UPGRADE: ExopackUpgradeItem by registry.register("exopack_smelting_upgrade") { ExopackUpgradeItem(MatteryPlayer.UpgradeType.SMELTING, "smelting_upgrade", "smelting_installed") } - val ENDER_UPGRADE: ExopackUpgradeItem by registry.register("exopack_ender_upgrade") { ExopackUpgradeItem(MatteryPlayer.UpgradeType.ENDER_ACCESS, "ender_access_upgrade", "ender_access_installed") } + val CRAFTING_UPGRADE: ExopackUpgradeItem by registry.register("exosuit_crafting_upgrade") { ExopackUpgradeItem( + MatteryPlayer.UpgradeType.CRAFTING, "crafting_upgrade", "crafting_upgraded") } + val SMELTING_UPGRADE: ExopackUpgradeItem by registry.register("exopack_smelting_upgrade") { ExopackUpgradeItem( + MatteryPlayer.UpgradeType.SMELTING, "smelting_upgrade", "smelting_installed") } + val ENDER_UPGRADE: ExopackUpgradeItem by registry.register("exopack_ender_upgrade") { ExopackUpgradeItem( + MatteryPlayer.UpgradeType.ENDER_ACCESS, "ender_access_upgrade", "ender_access_installed") } val INVENTORY_UPGRADES = SupplierList(8) { registry.register("exosuit_inventory_upgrade_$it") { ExopackSlotUpgradeItem(18, Rarity.COMMON) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/ExopackCommand.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/ExopackCommand.kt index b95f3e460..04573bf3a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/ExopackCommand.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/ExopackCommand.kt @@ -5,7 +5,7 @@ import net.minecraft.commands.arguments.EntityArgument import net.minecraft.world.entity.player.Player import net.neoforged.neoforge.event.RegisterCommandsEvent import net.neoforged.neoforge.server.command.EnumArgument -import ru.dbotthepony.mc.otm.capability.MatteryPlayer.UpgradeType +import ru.dbotthepony.mc.otm.player.MatteryPlayer.UpgradeType import ru.dbotthepony.mc.otm.player.matteryPlayer object ExopackCommand { 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 e7e4c8b38..35abe1315 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt @@ -11,7 +11,7 @@ import net.minecraft.util.StringRepresentable import net.minecraft.world.entity.monster.ElderGuardian import net.neoforged.neoforge.event.entity.living.LivingDeathEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.data.codec.SingletonCodec From 0424dd1944b4a8f2d4f57878467e2385d456056c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 12 Mar 2025 19:34:26 +0700 Subject: [PATCH 03/46] Rename mattery player reference 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 3ac192f23..7e74e0071 100644 --- a/src/main/resources/coremods/code_injector.js +++ b/src/main/resources/coremods/code_injector.js @@ -585,7 +585,7 @@ function initializeCoreMod() { new VarInsnNode(opcodesRemapped.aload, 0), new MethodInsnNode( opcodesRemapped.invokestatic, - 'ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability', + 'ru/dbotthepony/mc/otm/player/MatteryPlayer', 'addEatEffectHook', '(Ljava/util/Iterator;Lnet/minecraft/world/entity/LivingEntity;)Ljava/util/Iterator;' ), From cfd6b101d8269c6862787237abdac22ae29ec959 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 12 Mar 2025 20:31:59 +0700 Subject: [PATCH 04/46] Fix addEatEffect hook --- .../kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt | 5 +++-- src/main/resources/coremods/code_injector.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt index c69c2a785..f758b929c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt @@ -29,6 +29,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.food.FoodProperties import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ProjectileWeaponItem @@ -1521,14 +1522,14 @@ class MatteryPlayer(val ply: Player) { * hooked into LivingEntity through coremod script */ @JvmStatic - fun addEatEffectHook(iterator: Iterator>, entity: LivingEntity): Iterator> { + fun addEatEffectHook(iterator: Iterator, entity: LivingEntity): Iterator { if (entity !is Player) { return iterator } if (entity.matteryPlayer.isAndroid) { return iterator.filter { - it.first.effect != MobEffects.HUNGER + it.effect().effect != MobEffects.HUNGER } } diff --git a/src/main/resources/coremods/code_injector.js b/src/main/resources/coremods/code_injector.js index 7e74e0071..bd543beb8 100644 --- a/src/main/resources/coremods/code_injector.js +++ b/src/main/resources/coremods/code_injector.js @@ -576,7 +576,7 @@ function backtrack(instructions, from, opcode, skipAmount) { function initializeCoreMod() { return { - '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) { + 'LivingEntity#addEatEffect patch for androids': method('net.minecraft.world.entity.LivingEntity.addEatEffect(Lnet/minecraft/world/food/FoodProperties;)V', function(node) { for (var i = 0; i < node.instructions.size(); i++) { var instr = node.instructions.get(i) From c3b2681e89682f879b7bbf1f165c02831adf90b5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 12 Mar 2025 20:57:57 +0700 Subject: [PATCH 05/46] Rename AndroidConfig to PlayerConfig --- .../mc/otm/OverdriveThatMatters.kt | 4 +- .../otm/android/AndroidResearchDescription.kt | 16 +++---- .../android/feature/EnderTeleporterFeature.kt | 26 ++++++------ .../android/feature/FallDampenersFeature.kt | 6 +-- .../otm/android/feature/ItemMagnetFeature.kt | 10 ++--- .../otm/android/feature/JumpBoostFeature.kt | 8 ++-- .../feature/NanobotsRegenerationFeature.kt | 8 ++-- .../otm/android/feature/NightVisionFeature.kt | 4 +- .../otm/android/feature/ShockwaveFeature.kt | 26 ++++++------ .../android/feature/SwimBoostersFeature.kt | 4 +- .../mc/otm/client/render/ShockwaveRenderer.kt | 4 +- .../{AndroidConfig.kt => PlayerConfig.kt} | 2 +- .../mc/otm/network/AndroidPackets.kt | 4 +- .../mc/otm/player/MatteryPlayer.kt | 42 +++++++++---------- 14 files changed, 82 insertions(+), 82 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/config/{AndroidConfig.kt => PlayerConfig.kt} (99%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt index d32ffc843..b9c7345e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt @@ -43,7 +43,7 @@ import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer import ru.dbotthepony.mc.otm.compat.curios.isCuriosLoaded import ru.dbotthepony.mc.otm.compat.curios.onCuriosSlotModifiersUpdated import ru.dbotthepony.mc.otm.compat.vanilla.MatteryChestMenu -import ru.dbotthepony.mc.otm.config.AndroidConfig +import ru.dbotthepony.mc.otm.config.PlayerConfig import ru.dbotthepony.mc.otm.config.CablesConfig import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.config.ExopackConfig @@ -170,7 +170,7 @@ object OverdriveThatMatters { ClientConfig.register(container) ServerConfig.register(container) CablesConfig.register(container) - AndroidConfig.register(container) + PlayerConfig.register(container) ExopackConfig.register(container) ItemsConfig.register(container) MachinesConfig.register(container) 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 b34bbc302..1a53c7e37 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt @@ -9,7 +9,7 @@ import net.minecraft.network.chat.ComponentSerialization import net.neoforged.bus.api.IEventBus 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.config.PlayerConfig import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.util.formatPower @@ -29,14 +29,14 @@ object AndroidResearchDescriptions { 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)) } + TranslatableComponent("otm.gui.power_cost_per_use", PlayerConfig.EnderTeleporter.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW)) } } val FALL_DAMPENERS: AndroidResearchDescription.Leveled by registrar.register("fall_dampeners") { 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), + TextComponent("%.1f".format((PlayerConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_P * level).toFloat().coerceIn(0f, 1f) * 100f)).withStyle(ChatFormatting.YELLOW), + TextComponent("%.1f".format((PlayerConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_F * level).toFloat())).withStyle(ChatFormatting.YELLOW), )) } } @@ -44,20 +44,20 @@ object AndroidResearchDescriptions { 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) + TextComponent("%.1f".format(PlayerConfig.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)) } + AndroidResearchDescription.singleton { TranslatableComponent("otm.gui.power_cost_per_tick", PlayerConfig.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)) } + AndroidResearchDescription.singleton { TranslatableComponent("otm.gui.power_cost_per_use", PlayerConfig.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)) } + AndroidResearchDescription.singleton { TranslatableComponent("otm.gui.power_cost_per_use", PlayerConfig.Shockwave.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW)) } } } 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 501c25147..35bad8f25 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.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.client.render.linesIgnoreZRenderType import ru.dbotthepony.mc.otm.client.render.sprites.sprite -import ru.dbotthepony.mc.otm.config.AndroidConfig +import ru.dbotthepony.mc.otm.config.PlayerConfig import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.core.genericPositions import ru.dbotthepony.mc.otm.core.holder @@ -60,10 +60,10 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A private set override val maxCooldown: Int - get() = AndroidConfig.EnderTeleporter.COOLDOWN + get() = PlayerConfig.EnderTeleporter.COOLDOWN private fun canUse(): Boolean { - return !isOnCooldown && android.androidEnergy.extractEnergyExact(AndroidConfig.EnderTeleporter.ENERGY_COST, true) + return !isOnCooldown && android.androidEnergy.extractEnergyExact(PlayerConfig.EnderTeleporter.ENERGY_COST, true) } private fun isValidGround(blockPos: BlockPos): Boolean { @@ -112,14 +112,14 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A } private fun tryToPhaseThroughWall(blockPos: BlockPos, normal: Vec3i): TraceResult? { - val phasedBlocks = ArrayList(AndroidConfig.EnderTeleporter.MAX_PHASE_DISTANCE) + val phasedBlocks = ArrayList(PlayerConfig.EnderTeleporter.MAX_PHASE_DISTANCE) phasedBlocks.add(blockPos) - for (extend in 1 .. AndroidConfig.EnderTeleporter.MAX_PHASE_DISTANCE) { + for (extend in 1 .. PlayerConfig.EnderTeleporter.MAX_PHASE_DISTANCE) { val pos = blockPos + normal * extend if (isAirGap(pos)) { - for (y in 0 .. AndroidConfig.EnderTeleporter.MAX_PHASE_DISTANCE - extend) { + for (y in 0 .. PlayerConfig.EnderTeleporter.MAX_PHASE_DISTANCE - extend) { val newPos = BlockPos(pos.x, pos.y - y, pos.z) if (isValidPosition(newPos)) { @@ -142,7 +142,7 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A val result = ply.level().clip(ClipContext( headPosition, - headPosition + aimVector * (AndroidConfig.EnderTeleporter.MAX_DISTANCE * 2.0), + headPosition + aimVector * (PlayerConfig.EnderTeleporter.MAX_DISTANCE * 2.0), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, ply @@ -158,7 +158,7 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A !ply.isShiftKeyDown && result.direction == Direction.UP && isValidPosition(result.blockPos.above()) && - shortestDistanceBetween(testPositions, result.blockPos.above().asVector()) <= AndroidConfig.EnderTeleporter.MAX_DISTANCE + shortestDistanceBetween(testPositions, result.blockPos.above().asVector()) <= PlayerConfig.EnderTeleporter.MAX_DISTANCE ) { return TraceResult(result.blockPos.above()) } @@ -216,14 +216,14 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A if (!isAirGap(pos)) { phasedBlocks++ - if (phasedBlocks >= AndroidConfig.EnderTeleporter.MAX_PHASE_DISTANCE) { + if (phasedBlocks >= PlayerConfig.EnderTeleporter.MAX_PHASE_DISTANCE) { break } phasedBlocksList.add(pos) } - if (shortestDistanceBetween(testPositions, pos.asVector()) > AndroidConfig.EnderTeleporter.MAX_DISTANCE) { + if (shortestDistanceBetween(testPositions, pos.asVector()) > PlayerConfig.EnderTeleporter.MAX_DISTANCE) { break } @@ -270,14 +270,14 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A if (!isAirGap(pos)) { phasedBlocks++ - if (phasedBlocks >= AndroidConfig.EnderTeleporter.MAX_PHASE_DISTANCE) { + if (phasedBlocks >= PlayerConfig.EnderTeleporter.MAX_PHASE_DISTANCE) { break } phasedBlocksList.add(pos) } - if (shortestDistanceBetween(testPositions, pos.asVector()) > AndroidConfig.EnderTeleporter.MAX_DISTANCE) { + if (shortestDistanceBetween(testPositions, pos.asVector()) > PlayerConfig.EnderTeleporter.MAX_DISTANCE) { break } @@ -308,7 +308,7 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A putOnCooldown() lastTeleport = ply.server!!.tickCount - android.androidEnergy.extractEnergy(AndroidConfig.EnderTeleporter.ENERGY_COST, false) + android.androidEnergy.extractEnergy(PlayerConfig.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/FallDampenersFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt index 59e4e4d37..0ab545303 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 @@ -4,7 +4,7 @@ import net.minecraft.server.level.ServerPlayer import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer -import ru.dbotthepony.mc.otm.config.AndroidConfig +import ru.dbotthepony.mc.otm.config.PlayerConfig import ru.dbotthepony.mc.otm.core.isFall import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger @@ -12,8 +12,8 @@ import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger class FallDampenersFeature(capability: MatteryPlayer) : AndroidFeature(AndroidFeatures.FALL_DAMPENERS, capability) { override fun onHurt(event: LivingIncomingDamageEvent) { 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) + val reduction = (PlayerConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_P * (level + 1)).toFloat().coerceIn(0f, 1f) + val flat = (PlayerConfig.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) 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 fd4627d00..679f8f767 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 @@ -11,7 +11,7 @@ import net.neoforged.neoforge.network.PacketDistributor import net.neoforged.neoforge.network.handling.IPayloadContext import ru.dbotthepony.kommons.math.RGBAColor import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.config.AndroidConfig +import ru.dbotthepony.mc.otm.config.PlayerConfig import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact @@ -76,13 +76,13 @@ class ItemMagnetFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(An 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(AndroidConfig.Magnet.POWER_DRAW, true)) { + if (ply.isSpectator || server && !android.androidEnergy.extractEnergyExact(PlayerConfig.Magnet.POWER_DRAW, true)) { return } val entities = ply.level().getEntitiesInEllipsoid( ply.position, - Vector(AndroidConfig.Magnet.RADIUS_HORIZONTAL, AndroidConfig.Magnet.RADIUS_VERTICAL, AndroidConfig.Magnet.RADIUS_HORIZONTAL), + Vector(PlayerConfig.Magnet.RADIUS_HORIZONTAL, PlayerConfig.Magnet.RADIUS_VERTICAL, PlayerConfig.Magnet.RADIUS_HORIZONTAL), if (server) Predicate { it is ItemEntity } else clientPredicate ) @@ -101,7 +101,7 @@ class ItemMagnetFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(An if (data.position.distanceToSqr(ent.position) < 1.0) { data.ticksSinceActivity++ } else { - if (!android.androidEnergy.extractEnergyExact(AndroidConfig.Magnet.POWER_DRAW, false)) { + if (!android.androidEnergy.extractEnergyExact(PlayerConfig.Magnet.POWER_DRAW, false)) { return } @@ -117,7 +117,7 @@ class ItemMagnetFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(An override fun tickClient() { super.tickClient() - if (!ply.isSpectator && isActive && android.androidEnergy.extractEnergyExact(AndroidConfig.Magnet.POWER_DRAW, true)) { + if (!ply.isSpectator && isActive && android.androidEnergy.extractEnergyExact(PlayerConfig.Magnet.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 b81c5b3c4..073327eda 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 @@ -11,7 +11,7 @@ import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact 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.PlayerConfig import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.plus @@ -24,7 +24,7 @@ class JumpBoostFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And private var tickCooldownClient = false override val maxCooldown: Int - get() = (AndroidConfig.JumpBoost.BASE_COOLDOWN - AndroidConfig.JumpBoost.COOLDOWN_REDUCTION * level).coerceAtLeast(0) + get() = (PlayerConfig.JumpBoost.BASE_COOLDOWN - PlayerConfig.JumpBoost.COOLDOWN_REDUCTION * level).coerceAtLeast(0) override var cooldown by syncher.int(setter = setter@{ access, value -> access.accept(value) @@ -46,8 +46,8 @@ class JumpBoostFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And val old = lastGround 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) + if (isActive && cooldown <= 0 && old != lastGround && !lastGround && isJumping && isShifting && ply.xRot <= ClientConfig.JUMP_BOOST_LOOK_ANGLE && android.androidEnergy.extractEnergyExact(PlayerConfig.JumpBoost.ENERGY_COST, true)) { + ply.deltaMovement += Vector(0.0, PlayerConfig.JumpBoost.POWER * (level + 1) / 20.0, 0.0) putOnCooldown() PacketDistributor.sendToServer(TriggerJumpBoostPacket) 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 d2edf3af3..23a06c150 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 @@ -5,7 +5,7 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.server.level.ServerPlayer import net.minecraft.world.level.GameRules import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent -import ru.dbotthepony.mc.otm.config.AndroidConfig +import ru.dbotthepony.mc.otm.config.PlayerConfig import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures @@ -21,16 +21,16 @@ class NanobotsRegenerationFeature(android: MatteryPlayer) : AndroidFeature(Andro if (ply.isHurt && ply.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { ticksPassed++ - val waitTime = AndroidConfig.NanobotsRegeneration.COOLDOWN.getOrElse(healTicks) { AndroidConfig.NanobotsRegeneration.COOLDOWN.last() } + val waitTime = PlayerConfig.NanobotsRegeneration.COOLDOWN.getOrElse(healTicks) { PlayerConfig.NanobotsRegeneration.COOLDOWN.last() } if (ticksPassed > waitTime) { val missingHealth = (ply.maxHealth - ply.health).coerceAtMost(2f) - val power = AndroidConfig.NanobotsRegeneration.ENERGY_PER_HITPOINT * missingHealth + val power = PlayerConfig.NanobotsRegeneration.ENERGY_PER_HITPOINT * missingHealth val extracted = android.androidEnergy.extractEnergy(power, false) if (extracted.isPositive) { healTicks = (healTicks + 1).coerceAtMost(level) - val healed = (extracted / AndroidConfig.NanobotsRegeneration.ENERGY_PER_HITPOINT).toFloat() + val healed = (extracted / PlayerConfig.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 d3b676b82..c4c3d9df4 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,7 +8,7 @@ import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact 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.PlayerConfig import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures class NightVisionFeature(android: MatteryPlayer) : AndroidSwitchableFeature(AndroidFeatures.NIGHT_VISION, android) { @@ -19,7 +19,7 @@ class NightVisionFeature(android: MatteryPlayer) : AndroidSwitchableFeature(Andr if (isActive) { val effect = android.ply.activeEffectsMap[MobEffects.NIGHT_VISION] - if ((effect == null || effect.duration < 220) && (ply.isSpectator || android.androidEnergy.extractEnergyExact(AndroidConfig.NIGHT_VISION_POWER_DRAW, false))) { + if ((effect == null || effect.duration < 220) && (ply.isSpectator || android.androidEnergy.extractEnergyExact(PlayerConfig.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 c38754b02..a78b9fe14 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,7 +12,7 @@ import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact 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.PlayerConfig import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid import ru.dbotthepony.mc.otm.core.getExplosionResistance @@ -37,7 +37,7 @@ import kotlin.math.roundToInt class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(AndroidFeatures.SHOCKWAVE, capability) { override val maxCooldown: Int - get() = AndroidConfig.Shockwave.COOLDOWN + get() = PlayerConfig.Shockwave.COOLDOWN private var wasMidair = false private var highestSpeed = 0.0 @@ -52,18 +52,18 @@ class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And isActive && ply.isShiftKeyDown && !isOnCooldown && - android.androidEnergy.extractEnergyExact(AndroidConfig.Shockwave.ENERGY_COST, true) && + android.androidEnergy.extractEnergyExact(PlayerConfig.Shockwave.ENERGY_COST, true) && ply.deltaMovement.y < -0.01 && creativeFlightTicks == 0 ) { - ply.deltaMovement += Vector(0.0, -AndroidConfig.Shockwave.ACCELERATION / 20.0, 0.0) + ply.deltaMovement += Vector(0.0, -PlayerConfig.Shockwave.ACCELERATION / 20.0, 0.0) } ticker(true) } fun shockwave() { - if (ply.isSpectator || isOnCooldown || !android.androidEnergy.extractEnergyExact(AndroidConfig.Shockwave.ENERGY_COST, false)) { + if (ply.isSpectator || isOnCooldown || !android.androidEnergy.extractEnergyExact(PlayerConfig.Shockwave.ENERGY_COST, false)) { return } @@ -86,14 +86,14 @@ class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And // TODO: raycasting val entities = ply.level().getEntitiesInEllipsoid( ply.position, - Vector(AndroidConfig.Shockwave.RADIUS_HORIZONTAL, AndroidConfig.Shockwave.RADIUS_VERTICAL, AndroidConfig.Shockwave.RADIUS_HORIZONTAL), + Vector(PlayerConfig.Shockwave.RADIUS_HORIZONTAL, PlayerConfig.Shockwave.RADIUS_VERTICAL, PlayerConfig.Shockwave.RADIUS_HORIZONTAL), except = ply, ) { (it !is LivingEntity || !it.isSpectator && it.isAlive) } 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), + Vector(PlayerConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN, PlayerConfig.Shockwave.RADIUS_VERTICAL_WARDEN, PlayerConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN), ) { true } val seen = ReferenceArraySet() @@ -103,7 +103,7 @@ class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And val multiplier = (1.0 - distanceMultiplier).pow(0.5) val source = MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply) - val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat() * AndroidConfig.Shockwave.WARDEN_DAMAGE_MULT.toFloat() + val damage = multiplier.toFloat() * PlayerConfig.Shockwave.DAMAGE.toFloat() * PlayerConfig.Shockwave.WARDEN_DAMAGE_MULT.toFloat() entity.hurt(source, damage) entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0) @@ -119,7 +119,7 @@ class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And // don't hurt items, arrows, etc etc if (entity is LivingEntity) { val source = MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply) - val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat() + val damage = multiplier.toFloat() * PlayerConfig.Shockwave.DAMAGE.toFloat() entity.hurt(source, damage) entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0) @@ -132,10 +132,10 @@ class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And } } - if (AndroidConfig.Shockwave.BREAK_BLOCKS) { + if (PlayerConfig.Shockwave.BREAK_BLOCKS) { val rounded = ply.position.roundToIntVector() - for (blockPos in getEllipsoidBlockPositions(AndroidConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt(), AndroidConfig.Shockwave.RADIUS_VERTICAL.roundToInt(), AndroidConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt())) { + for (blockPos in getEllipsoidBlockPositions(PlayerConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt(), PlayerConfig.Shockwave.RADIUS_VERTICAL.roundToInt(), PlayerConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt())) { val newBlockPos = blockPos + rounded val blockState = ply.level().getBlockState(newBlockPos) @@ -168,7 +168,7 @@ class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And !ply.isSpectator && isActive && !isOnCooldown && - android.androidEnergy.extractEnergyExact(AndroidConfig.Shockwave.ENERGY_COST, true) && + android.androidEnergy.extractEnergyExact(PlayerConfig.Shockwave.ENERGY_COST, true) && creativeFlightTicks == 0 ) { val old = wasMidair @@ -178,7 +178,7 @@ class ShockwaveFeature(capability: MatteryPlayer) : AndroidSwitchableFeature(And highestSpeed = (-ply.deltaMovement.y).coerceAtLeast(highestSpeed) } - if (old != wasMidair && !wasMidair && AndroidConfig.Shockwave.TERMINAL_VELOCITY <= (highestSpeed * 20.0) && ply.isShiftKeyDown) { + if (old != wasMidair && !wasMidair && PlayerConfig.Shockwave.TERMINAL_VELOCITY <= (highestSpeed * 20.0) && ply.isShiftKeyDown) { if (isClient) { // I HATE SELF-UPDATING PLAYERS // I HATE SELF-UPDATING PLAYERS 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 35b7d952b..4f9c16ceb 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 @@ -6,7 +6,7 @@ import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.player.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.config.PlayerConfig import ru.dbotthepony.kommons.math.RGBAColor import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.core.ResourceLocation @@ -20,7 +20,7 @@ class SwimBoostersFeature(android: MatteryPlayer) : AndroidSwitchableFeature(And val attr = ply.getAttribute(NeoForgeMod.SWIM_SPEED) ?: return attr.removeModifier(MODIFIER_ID) - attr.addPermanentModifier(AttributeModifier(MODIFIER_ID, (level + 1) * AndroidConfig.SWIM_BOOSTERS, AttributeModifier.Operation.ADD_VALUE)) + attr.addPermanentModifier(AttributeModifier(MODIFIER_ID, (level + 1) * PlayerConfig.SWIM_BOOSTERS, AttributeModifier.Operation.ADD_VALUE)) } override fun removeModifiers() { 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 1c4515def..7dddcfc17 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.neoforged.neoforge.client.event.RenderLevelStageEvent import org.lwjgl.opengl.GL11.GL_LESS -import ru.dbotthepony.mc.otm.config.AndroidConfig +import ru.dbotthepony.mc.otm.config.PlayerConfig import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.component1 import ru.dbotthepony.mc.otm.core.math.component2 @@ -74,6 +74,6 @@ object ShockwaveRenderer { } fun handle(packet: ShockwaveEffectPacket) { - State(packet.pos, AndroidConfig.Shockwave.RADIUS_HORIZONTAL.toFloat()) + State(packet.pos, PlayerConfig.Shockwave.RADIUS_HORIZONTAL.toFloat()) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt index f49f231d9..90ca28b22 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt @@ -4,7 +4,7 @@ import ru.dbotthepony.kommons.util.getValue import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.defineDecimal -object AndroidConfig : AbstractConfig("androids") { +object PlayerConfig : AbstractConfig("player") { 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") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/AndroidPackets.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/AndroidPackets.kt index 68701227b..74a49b8e6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/AndroidPackets.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/AndroidPackets.kt @@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.MatteryGUI import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.GlitchRenderer -import ru.dbotthepony.mc.otm.config.AndroidConfig +import ru.dbotthepony.mc.otm.config.PlayerConfig import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.core.readComponent import ru.dbotthepony.mc.otm.core.writeComponent @@ -366,7 +366,7 @@ object TriggerJumpBoostPacket : CustomPacketPayload { val feature = mattery.getFeature(AndroidFeatures.JUMP_BOOST) ?: return - if (feature.isActive && feature.cooldown <= 4 && mattery.androidEnergy.extractEnergyExact(AndroidConfig.JumpBoost.ENERGY_COST, false)) { + if (feature.isActive && feature.cooldown <= 4 && mattery.androidEnergy.extractEnergyExact(PlayerConfig.JumpBoost.ENERGY_COST, false)) { feature.putOnCooldown() context.player().level().playSound( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt index f758b929c..bde1b88f8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt @@ -78,7 +78,7 @@ import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.energy.receiveEnergyExact import ru.dbotthepony.mc.otm.capability.receiveEnergy import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.config.AndroidConfig +import ru.dbotthepony.mc.otm.config.PlayerConfig import ru.dbotthepony.mc.otm.config.ExopackConfig import ru.dbotthepony.mc.otm.container.CombinedContainer import ru.dbotthepony.mc.otm.container.DynamicallyProxiedContainer @@ -561,7 +561,7 @@ class MatteryPlayer(val ply: Player) { /** * [IMatteryEnergyStorage] instance, representing Android' battery charge */ - val androidEnergy = BatteryBackedEnergyStorage(ply, syncher, AndroidConfig.ANDROID_MAX_ENERGY, AndroidConfig.ANDROID_MAX_ENERGY, true) + val androidEnergy = BatteryBackedEnergyStorage(ply, syncher, PlayerConfig.ANDROID_MAX_ENERGY, PlayerConfig.ANDROID_MAX_ENERGY, true) /** * [IMatteryEnergyStorage] instance, representing Exopack battery charge @@ -659,8 +659,8 @@ class MatteryPlayer(val ply: Player) { shouldPlaySound = false iteration = 0 deathLog.clear() - androidEnergy.batteryLevel = AndroidConfig.ANDROID_MAX_ENERGY - androidEnergy.maxBatteryLevel = AndroidConfig.ANDROID_MAX_ENERGY + androidEnergy.batteryLevel = PlayerConfig.ANDROID_MAX_ENERGY + androidEnergy.maxBatteryLevel = PlayerConfig.ANDROID_MAX_ENERGY lastLiquidPosition = ply.position() wasInLiquid = false @@ -714,7 +714,7 @@ class MatteryPlayer(val ply: Player) { iteration = 0 deathLog.clear() androidEnergy.batteryLevel = Decimal.ZERO - androidEnergy.maxBatteryLevel = AndroidConfig.ANDROID_MAX_ENERGY + androidEnergy.maxBatteryLevel = PlayerConfig.ANDROID_MAX_ENERGY dropBattery() lastLiquidPosition = ply.position() @@ -1215,26 +1215,26 @@ class MatteryPlayer(val ply: Player) { } val stats = ply.foodData - val fourTimesTheHunger = AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT * 4 + val fourTimesTheHunger = PlayerConfig.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) + val extracted = androidEnergy.extractEnergy(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (stats.exhaustionLevel / 4f), false) + stats.setExhaustion(stats.exhaustionLevel - (extracted / PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat() * 4f) } // Обычный голод while ( stats.foodLevel < 18 && androidEnergy.batteryLevel >= fourTimesTheHunger && - androidEnergy.extractEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) + androidEnergy.extractEnergyExact(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) ) { stats.foodLevel++ } // "поглощение" излишек голода, как при мирном режиме, так и при поедании обычной еды - if (AndroidConfig.REGENERATE_ENERGY) { - while (stats.foodLevel > 18 && androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT / 2, false)) { + if (PlayerConfig.REGENERATE_ENERGY) { + while (stats.foodLevel > 18 && androidEnergy.receiveEnergyExact(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT / 2, false)) { stats.foodLevel-- } } else if (ply.level().difficulty != Difficulty.PEACEFUL) { @@ -1245,22 +1245,22 @@ class MatteryPlayer(val ply: Player) { // насыщение 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()) + val extracted = androidEnergy.extractEnergy(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (foodLevel - stats.saturationLevel), false) + stats.setSaturation(stats.saturationLevel + (extracted / PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat()) } 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)) { + if (androidEnergy.receiveEnergyExact(PlayerConfig.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()) + val received = androidEnergy.receiveEnergy(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * stats.saturationLevel, false) + stats.setSaturation(stats.saturationLevel - (received / PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat()) } else if (stats.foodLevel > 0) { // так как голод не тикает для андроидов, "умереть с голоду" мы не можем // но со стороны будет выглядеть как будто мы умираем с голода - if (androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)) { + if (androidEnergy.receiveEnergyExact(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)) { stats.foodLevel-- } } @@ -1281,11 +1281,11 @@ class MatteryPlayer(val ply: Player) { 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 PlayerConfig.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 PlayerConfig.TIME_BETWEEN_NATURAL_REGENERATION } } } @@ -1476,8 +1476,8 @@ class MatteryPlayer(val ply: Player) { ply.matteryPlayer.shouldSendIteration = true ply.matteryPlayer.deathLog.addLast(ply.tickCount to ply.combatTracker.deathMessage) - if (ply.matteryPlayer.androidEnergy.batteryLevel < AndroidConfig.ANDROID_MAX_ENERGY * Decimal("0.2")) - ply.matteryPlayer.androidEnergy.batteryLevel = AndroidConfig.ANDROID_MAX_ENERGY * Decimal("0.2") // если смерть была от разряда батареи, то предотвращаем софтлок + if (ply.matteryPlayer.androidEnergy.batteryLevel < PlayerConfig.ANDROID_MAX_ENERGY * Decimal("0.2")) + ply.matteryPlayer.androidEnergy.batteryLevel = PlayerConfig.ANDROID_MAX_ENERGY * Decimal("0.2") // если смерть была от разряда батареи, то предотвращаем софтлок while (ply.matteryPlayer.deathLog.size > 6) { ply.matteryPlayer.deathLog.removeFirst() From a34b485e685eb207cb15105e544d0dc2b9478e07 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Mar 2025 08:52:36 +0700 Subject: [PATCH 06/46] Base replacement for FoodData --- .../mc/otm/mixin/FoodDataMixin.java | 50 -------- .../dbotthepony/mc/otm/mixin/MixinPlayer.java | 17 ++- .../mc/otm/config/IFoodRegenerationValues.kt | 9 ++ .../dbotthepony/mc/otm/config/PlayerConfig.kt | 99 +++++++++++++++ .../mc/otm/player/MatteryFoodData.kt | 119 ++++++++++++++++++ .../resources/META-INF/accesstransformer.cfg | 6 + .../overdrive_that_matters.mixins.json | 1 - 7 files changed, 249 insertions(+), 52 deletions(-) delete mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/config/IFoodRegenerationValues.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java deleted file mode 100644 index 2b00f3d4f..000000000 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java +++ /dev/null @@ -1,50 +0,0 @@ -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.player.IMatteryPlayer; - -@Mixin(FoodData.class) -public class FoodDataMixin { - @Shadow(remap = false) - private int lastFoodLevel; - @Shadow(remap = false) - private int tickTimer; - @Shadow(remap = false) - private int foodLevel; - @Shadow(remap = false) - private float exhaustionLevel; - - @Inject( - method = "tick(Lnet/minecraft/world/entity/player/Player;)V", - at = @At("HEAD"), - remap = false, - cancellable = true - ) - private void tick(Player player, CallbackInfo info) { - var it = ((IMatteryPlayer) player).getOtmPlayer(); - - if (it.isAndroid()) { - info.cancel(); - - // полностью подменяем логику если андроид - lastFoodLevel = foodLevel; - - if (player.level().getDifficulty() == Difficulty.PEACEFUL) { - exhaustionLevel = 0f; - } else { - tickTimer = 0; - } - - // не обновляем уровень истощения ибо он обнуляется логикой внутри MatteryPlayerCapability - // а так же не регенерируем - // ну и не получаем урон от "голодания" - } - } -} diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java index bcde0cf79..c6f691361 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java @@ -4,21 +4,25 @@ import com.mojang.authlib.GameProfile; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.food.FoodData; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; 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.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import ru.dbotthepony.mc.otm.player.IMatteryPlayer; +import ru.dbotthepony.mc.otm.player.MatteryFoodData; import ru.dbotthepony.mc.otm.player.MatteryPlayer; import java.util.Objects; @Mixin(Player.class) -public class MixinPlayer implements IMatteryPlayer { +public abstract class MixinPlayer implements IMatteryPlayer { private Player otmSelf() { return (Player) (Object) this; } @@ -85,4 +89,15 @@ public class MixinPlayer implements IMatteryPlayer { private void readAdditionalSaveData(CompoundTag data, CallbackInfo ci) { otmPlayer.deserializeNBT(data.getCompound("overdrive_that_matters_player"), otmSelf().registryAccess()); } + + @Shadow + protected FoodData foodData; + + @Inject( + method = "", + at = @At("TAIL") + ) + private void ctorMix() { + foodData = new MatteryFoodData(otmSelf()); + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/IFoodRegenerationValues.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/IFoodRegenerationValues.kt new file mode 100644 index 000000000..ab1e9e719 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/IFoodRegenerationValues.kt @@ -0,0 +1,9 @@ +package ru.dbotthepony.mc.otm.config + +interface IFoodRegenerationValues { + val foodLimit: Int + val requiresSaturation: Boolean + val ticks: Int + val regenerationSlowdown: Boolean + val upperSlowdownBound: Double +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt index 90ca28b22..fb5108a30 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt @@ -148,4 +148,103 @@ object PlayerConfig : AbstractConfig("player") { Magnet Shockwave } + + object Food { + init { + builder + .comment("Food related tweaks") + .comment("Since OTM overrides FoodData logic (to make room for Android logic)") + .comment("these settings are provided for tweaking FoodData behavior") + .push("Food") + } + + val SOFT_FOOD_LIMIT: Int by builder + .comment("Soft food points limit, which dictate upper bound where player is considered 'hungry',") + .comment("e.g. they can eat food which is not marked as 'can always eat'") + .defineInRange("SOFT_FOOD_LIMIT", 20, 0) + + val HARD_FOOD_LIMIT: Int by builder + .comment("Hard food points limit, which dictate upper bound of food points,") + .comment("e.g. hunger can not go above this value") + .comment("This is extremely buffed in OTM by default to remove annoyance regarding consuming foodstuffs") + .comment("when you are running low on food, so you can eat high-quality food without fear") + .comment("that food points will go to waste (especially when you need to regenerate lots of HP)") + .defineInRange("HARD_FOOD_LIMIT", 40, 1) + + val OVERSATURATION_LIMIT: Double by builder + .comment("Controls how much 'saturation' can be stored above hunger level.") + .comment("Negative values will decrease maximum saturation achievable.") + .defineInRange("OVERSATURATION_LIMIT", 0.0, -Float.MAX_VALUE.toDouble() + 1.0, Float.MAX_VALUE.toDouble() - 1.0) + + val EXHAUSTION_LIMIT: Double by builder + .comment("Controls technical aspect how much 'exhaustion' player can accumulate") + .comment("This should not be confused with how much 'exhaustion' is considered as 1 hunger point") + .comment("Usually, this should not be changed, since it is a very technical detail") + .comment("but if you have a mod installed which easily hits this limit (and somehow hunger system can't keep up,)") + .comment("e.g. it pushes exhaustion over its limit in one call), you can increase this value") + .defineInRange("EXHAUSTION_LIMIT", 40.0, 4.0, Float.MAX_VALUE.toDouble() - 1.0) + + private fun defineRegeneration( + threshold: Int, + requiresSaturation: Boolean, + ticks: Int, + ): IFoodRegenerationValues { + return object : IFoodRegenerationValues { + override val foodLimit: Int by builder + .defineInRange("FOOD_THRESHOLD", threshold, 1) + + override val requiresSaturation: Boolean by builder + .define("REQUIRES_SATURATION", requiresSaturation) + + override val ticks: Int by builder + .defineInRange("TICKS", ticks, 0) + + override val regenerationSlowdown: Boolean by builder + .comment("Slowdown regeneration based on remaining saturation (given REQUIRES_SATURATION is true)") + .comment("This replicates vanilla behavior where fast regeneration speed linearly slowdowns the moment") + .comment("saturation falls below 6 hunger points (configurable through SATURATION_SLOWDOWN_BOUND)") + .comment("This is disabled in OTM by default to buff humans compared to androids when it comes to regeneration") + .define("SATURATION_SLOWDOWN", false) + + override val upperSlowdownBound: Double by builder + .defineInRange("SATURATION_SLOWDOWN_BOUND", 6.0, 1.0, Float.MAX_VALUE - 1.0) + } + } + + val FAST_REGEN: IFoodRegenerationValues + val SLOW_REGEN: IFoodRegenerationValues + + init { + builder.push("FAST_REGENERATION") + FAST_REGEN = defineRegeneration(20, true, 10) + builder.pop() + + builder.push("SLOW_REGENERATION") + SLOW_REGEN = defineRegeneration(18, false, 80) + builder.pop() + } + + val ENABLE_STARVATION: Boolean by builder + .define("ENABLE_STARVATION", true) + + val STARVATION_TICKS: Int by builder + .defineInRange("STARVATION_TICKS", 80, 1) + + val STARVATION_HEALTH_LIMIT_EASY: Double by builder + .defineInRange("STARVATION_HEALTH_LIMIT_EASY", 10.0, 0.0) + + val STARVATION_HEALTH_LIMIT_NORMAL: Double by builder + .defineInRange("STARVATION_HEALTH_LIMIT_NORMAL", 1.0, 0.0) + + val STARVATION_HEALTH_LIMIT_HARD: Double by builder + .defineInRange("STARVATION_HEALTH_LIMIT_HARD", 0.0, 0.0) + + init { + builder.pop() + } + } + + init { + Food + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt new file mode 100644 index 000000000..1fc92dfa0 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt @@ -0,0 +1,119 @@ +package ru.dbotthepony.mc.otm.player + +import net.minecraft.nbt.CompoundTag +import net.minecraft.world.Difficulty +import net.minecraft.world.entity.player.Player +import net.minecraft.world.food.FoodConstants +import net.minecraft.world.food.FoodData +import net.minecraft.world.food.FoodProperties +import net.minecraft.world.level.GameRules +import ru.dbotthepony.mc.otm.config.IFoodRegenerationValues +import ru.dbotthepony.mc.otm.config.PlayerConfig +import ru.dbotthepony.mc.otm.core.nbt.set +import kotlin.math.max +import kotlin.math.min +import kotlin.math.roundToInt + +class MatteryFoodData(private var player: Player) : FoodData() { + private fun add(foodLevel: Int, saturation: Float) { + this.foodLevel = min(this.foodLevel + foodLevel, PlayerConfig.Food.HARD_FOOD_LIMIT) + this.saturationLevel = min(this.saturationLevel + saturation, this.foodLevel + PlayerConfig.Food.OVERSATURATION_LIMIT.toFloat()).coerceAtLeast(0f) + } + + override fun eat(foodLevelModifier: Int, saturationLevelModifier: Float) { + add(foodLevelModifier, FoodConstants.saturationByModifier(foodLevelModifier, saturationLevelModifier)) + } + + override fun eat(foodProperties: FoodProperties) { + add(foodProperties.nutrition(), foodProperties.saturation()) + } + + override fun needsFood(): Boolean { + return foodLevel < PlayerConfig.Food.SOFT_FOOD_LIMIT + } + + override fun addExhaustion(exhaustion: Float) { + this.exhaustionLevel = min(this.exhaustionLevel + exhaustion, PlayerConfig.Food.EXHAUSTION_LIMIT.toFloat()) + } + + override fun readAdditionalSaveData(compoundTag: CompoundTag) { + super.readAdditionalSaveData(compoundTag) + + if ("lastFoodLevel" in compoundTag) + lastFoodLevel = compoundTag.getInt("lastFoodLevel") + } + + override fun addAdditionalSaveData(compoundTag: CompoundTag) { + super.addAdditionalSaveData(compoundTag) + compoundTag["lastFoodLevel"] = lastFoodLevel + } + + private fun tickExhaustion() { + if (exhaustionLevel >= EXHAUSTION_PER_HUNGER_POINT) { + var points = (exhaustionLevel / EXHAUSTION_PER_HUNGER_POINT).toInt() + exhaustionLevel %= EXHAUSTION_PER_HUNGER_POINT + + if (saturationLevel > 0f) { + val satisfied = min(saturationLevel.roundToInt(), points) + points -= satisfied + saturationLevel -= satisfied + } + + foodLevel = max(0, foodLevel - points) + } + } + + private fun tickRegeneration(values: IFoodRegenerationValues): Boolean { + if (!player.isHurt || foodLevel < values.foodLimit || values.requiresSaturation && saturationLevel <= 0f) + return false + + while (player.isHurt && foodLevel >= values.foodLimit && (!values.requiresSaturation || saturationLevel > 0f) && ++tickTimer >= values.ticks) { + tickTimer = 0 + + val healAmount = if (values.requiresSaturation && values.regenerationSlowdown) min(saturationLevel, values.upperSlowdownBound.toFloat()) / values.upperSlowdownBound.toFloat() else 1f + player.heal(healAmount) + addExhaustion(healAmount * 6f) + tickExhaustion() + } + + return tickTimer != 0 + } + + override fun tick(player: Player) { + this.player = player + + if (player.matteryPlayer.isAndroid) + return + + lastFoodLevel = foodLevel + tickExhaustion() + + if ( + player.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION) && + (tickRegeneration(PlayerConfig.Food.FAST_REGEN) || tickRegeneration(PlayerConfig.Food.SLOW_REGEN)) + ) { + // do nothing + } else if (PlayerConfig.Food.ENABLE_STARVATION && foodLevel <= 0) { + if (++tickTimer >= PlayerConfig.Food.STARVATION_TICKS) { + tickTimer = 0 + + val threshold = when (player.level().difficulty) { + Difficulty.PEACEFUL -> Float.POSITIVE_INFINITY + Difficulty.EASY -> PlayerConfig.Food.STARVATION_HEALTH_LIMIT_EASY.toFloat() + Difficulty.NORMAL -> PlayerConfig.Food.STARVATION_HEALTH_LIMIT_NORMAL.toFloat() + Difficulty.HARD -> PlayerConfig.Food.STARVATION_HEALTH_LIMIT_HARD.toFloat() + } + + if (player.health > threshold) { + player.hurt(player.damageSources().starve(), 1.0f) + } + } + } else { + tickTimer = 0 + } + } + + companion object { + const val EXHAUSTION_PER_HUNGER_POINT = 4f + } +} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 981907976..131df1c03 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -176,3 +176,9 @@ public net.minecraft.advancements.critereon.InventoryChangeTrigger$TriggerInstan #public-f net.minecraft.advancements.critereon.SimpleCriterionTrigger removePlayerListeners(Lnet/minecraft/server/PlayerAdvancements;)V public net.minecraft.world.entity.npc.VillagerTrades$TreasureMapForEmeralds + +protected net.minecraft.world.food.FoodData foodLevel +protected net.minecraft.world.food.FoodData saturationLevel +protected net.minecraft.world.food.FoodData exhaustionLevel +protected net.minecraft.world.food.FoodData tickTimer +protected net.minecraft.world.food.FoodData lastFoodLevel diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index 934ead87e..5a114f337 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -7,7 +7,6 @@ "refmap": "overdrive_that_matters.refmap.json", "mixins": [ "BlockEntityMixin", - "FoodDataMixin", "MixinLivingEntity", "MixinAnvilBlock", "MixinInventory", From c4d5ffefa5c9bf89d402315bd64854824efade1f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Mar 2025 10:37:54 +0700 Subject: [PATCH 07/46] Move all logic regarding food / regeneration to MatteryFoodData --- .../dbotthepony/mc/otm/config/PlayerConfig.kt | 17 ++- .../mc/otm/player/MatteryFoodData.kt | 142 ++++++++++++++---- .../mc/otm/player/MatteryPlayer.kt | 82 +--------- 3 files changed, 129 insertions(+), 112 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt index fb5108a30..7bad9ab1c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt @@ -5,15 +5,22 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.defineDecimal object PlayerConfig : AbstractConfig("player") { + init { + builder.push("Android") + } + 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) + val REGENERATE_ENERGY_IN_PEACEFUL: Boolean by builder + .comment("Regenerate energy while in peaceful") + .comment("This is disabled by default because this is easily exploitable") + .define("REGENERATE_ENERGY_IN_PEACEFUL", false) + val TIME_BETWEEN_NATURAL_REGENERATION: Int by builder - .comment("Time in ticks between natural health regeneration ticks") + .comment("Time in ticks between natural health regeneration ticks for Android") .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.") @@ -24,6 +31,10 @@ object PlayerConfig : AbstractConfig("player") { .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) + init { + builder.pop() + } + object NanobotsRegeneration { init { builder.push("NanobotsRegeneration") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt index 1fc92dfa0..279438107 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt @@ -2,6 +2,9 @@ package ru.dbotthepony.mc.otm.player import net.minecraft.nbt.CompoundTag import net.minecraft.world.Difficulty +import net.minecraft.world.damagesource.DamageSource +import net.minecraft.world.effect.MobEffectInstance +import net.minecraft.world.effect.MobEffects import net.minecraft.world.entity.player.Player import net.minecraft.world.food.FoodConstants import net.minecraft.world.food.FoodData @@ -9,15 +12,24 @@ import net.minecraft.world.food.FoodProperties import net.minecraft.world.level.GameRules import ru.dbotthepony.mc.otm.config.IFoodRegenerationValues import ru.dbotthepony.mc.otm.config.PlayerConfig +import ru.dbotthepony.mc.otm.core.damageType +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.nbt.set +import ru.dbotthepony.mc.otm.registry.MDamageTypes import kotlin.math.max import kotlin.math.min import kotlin.math.roundToInt class MatteryFoodData(private var player: Player) : FoodData() { private fun add(foodLevel: Int, saturation: Float) { - this.foodLevel = min(this.foodLevel + foodLevel, PlayerConfig.Food.HARD_FOOD_LIMIT) - this.saturationLevel = min(this.saturationLevel + saturation, this.foodLevel + PlayerConfig.Food.OVERSATURATION_LIMIT.toFloat()).coerceAtLeast(0f) + if (player.matteryPlayer.isAndroid && PlayerConfig.REGENERATE_ENERGY) { + energyToDrain -= PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * foodLevel + PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * saturation + } else if (!player.matteryPlayer.isAndroid) { + this.foodLevel = min(this.foodLevel + foodLevel, PlayerConfig.Food.HARD_FOOD_LIMIT) + this.saturationLevel = min(this.saturationLevel + saturation, this.foodLevel + PlayerConfig.Food.OVERSATURATION_LIMIT.toFloat()).coerceAtLeast(0f) + } } override fun eat(foodLevelModifier: Int, saturationLevelModifier: Float) { @@ -29,11 +41,12 @@ class MatteryFoodData(private var player: Player) : FoodData() { } override fun needsFood(): Boolean { - return foodLevel < PlayerConfig.Food.SOFT_FOOD_LIMIT + return player.matteryPlayer.isAndroid || foodLevel < PlayerConfig.Food.SOFT_FOOD_LIMIT } override fun addExhaustion(exhaustion: Float) { - this.exhaustionLevel = min(this.exhaustionLevel + exhaustion, PlayerConfig.Food.EXHAUSTION_LIMIT.toFloat()) + // store exhaustion as usual, and handle its reduction in tick for both humans and androids + this.exhaustionLevel = min(this.exhaustionLevel + exhaustion, PlayerConfig.Food.EXHAUSTION_LIMIT.toFloat()).coerceAtLeast(0f) } override fun readAdditionalSaveData(compoundTag: CompoundTag) { @@ -41,25 +54,35 @@ class MatteryFoodData(private var player: Player) : FoodData() { if ("lastFoodLevel" in compoundTag) lastFoodLevel = compoundTag.getInt("lastFoodLevel") + + if ("foodAndroidEnergyToDrain" in compoundTag) + energyToDrain = compoundTag.getDecimal("foodAndroidEnergyToDrain") } override fun addAdditionalSaveData(compoundTag: CompoundTag) { super.addAdditionalSaveData(compoundTag) compoundTag["lastFoodLevel"] = lastFoodLevel + compoundTag["foodAndroidEnergyToDrain"] = energyToDrain } + private var energyToDrain = Decimal.ZERO + private fun tickExhaustion() { if (exhaustionLevel >= EXHAUSTION_PER_HUNGER_POINT) { var points = (exhaustionLevel / EXHAUSTION_PER_HUNGER_POINT).toInt() exhaustionLevel %= EXHAUSTION_PER_HUNGER_POINT - if (saturationLevel > 0f) { - val satisfied = min(saturationLevel.roundToInt(), points) - points -= satisfied - saturationLevel -= satisfied - } + if (player.matteryPlayer.isAndroid) { + energyToDrain += PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * points + } else { + if (saturationLevel > 0f) { + val satisfied = min(saturationLevel.roundToInt(), points) + points -= satisfied + saturationLevel -= satisfied + } - foodLevel = max(0, foodLevel - points) + foodLevel = max(0, foodLevel - points) + } } } @@ -82,37 +105,96 @@ class MatteryFoodData(private var player: Player) : FoodData() { override fun tick(player: Player) { this.player = player - if (player.matteryPlayer.isAndroid) - return - - lastFoodLevel = foodLevel tickExhaustion() - if ( - player.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION) && - (tickRegeneration(PlayerConfig.Food.FAST_REGEN) || tickRegeneration(PlayerConfig.Food.SLOW_REGEN)) - ) { - // do nothing - } else if (PlayerConfig.Food.ENABLE_STARVATION && foodLevel <= 0) { - if (++tickTimer >= PlayerConfig.Food.STARVATION_TICKS) { - tickTimer = 0 + if (player.matteryPlayer.isAndroid) { + if (energyToDrain > Decimal.ZERO) + energyToDrain -= player.matteryPlayer.androidEnergy.extractEnergy(energyToDrain, false) + else if (energyToDrain < Decimal.ZERO) + energyToDrain += player.matteryPlayer.androidEnergy.receiveEnergy(-energyToDrain, false) - val threshold = when (player.level().difficulty) { - Difficulty.PEACEFUL -> Float.POSITIVE_INFINITY - Difficulty.EASY -> PlayerConfig.Food.STARVATION_HEALTH_LIMIT_EASY.toFloat() - Difficulty.NORMAL -> PlayerConfig.Food.STARVATION_HEALTH_LIMIT_NORMAL.toFloat() - Difficulty.HARD -> PlayerConfig.Food.STARVATION_HEALTH_LIMIT_HARD.toFloat() + if (player.level().difficulty == Difficulty.PEACEFUL && PlayerConfig.REGENERATE_ENERGY_IN_PEACEFUL) + player.matteryPlayer.androidEnergy.receiveEnergy(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) + + if (!player.matteryPlayer.androidHasEnergy) { + if (++tickTimer >= 20 && player.hurt(DamageSource(player.level().registryAccess().damageType(MDamageTypes.ANDROID_DISCHARGE)), 1f)) { + tickTimer = 0 } - if (player.health > threshold) { - player.hurt(player.damageSources().starve(), 1.0f) + val effect = player.activeEffectsMap[MobEffects.MOVEMENT_SLOWDOWN] + + if (effect == null || effect.duration < 40 || effect.amplifier < 2) { + player.addEffect(MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, effect?.duration?.coerceAtLeast(60) ?: 60, effect?.amplifier?.coerceAtLeast(2) ?: 2, false, false)) + } + } else { + if (player.isHurt && player.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { + if (++tickTimer >= PlayerConfig.TIME_BETWEEN_NATURAL_REGENERATION) { + player.heal(1f) + addExhaustion(6f) + tickTimer = 0 + } + } else { + tickTimer = 0 } } } else { - tickTimer = 0 + lastFoodLevel = foodLevel + energyToDrain = Decimal.ZERO + + if ( + player.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION) && + (tickRegeneration(PlayerConfig.Food.FAST_REGEN) || tickRegeneration(PlayerConfig.Food.SLOW_REGEN)) + ) { + // do nothing + } else if (PlayerConfig.Food.ENABLE_STARVATION && foodLevel <= 0) { + if (++tickTimer >= PlayerConfig.Food.STARVATION_TICKS) { + tickTimer = 0 + + val threshold = when (player.level().difficulty) { + Difficulty.PEACEFUL -> Float.POSITIVE_INFINITY + Difficulty.EASY -> PlayerConfig.Food.STARVATION_HEALTH_LIMIT_EASY.toFloat() + Difficulty.NORMAL -> PlayerConfig.Food.STARVATION_HEALTH_LIMIT_NORMAL.toFloat() + Difficulty.HARD -> PlayerConfig.Food.STARVATION_HEALTH_LIMIT_HARD.toFloat() + } + + if (player.health > threshold) { + player.hurt(player.damageSources().starve(), 1.0f) + } + } + } else { + tickTimer = 0 + } } } + override fun getFoodLevel(): Int { + if (player.matteryPlayer.isAndroid) + return if (player.matteryPlayer.androidHasEnergy) PlayerConfig.Food.SOFT_FOOD_LIMIT else 0 + + return super.getFoodLevel() + } + + override fun getLastFoodLevel(): Int { + if (player.matteryPlayer.isAndroid) + return getFoodLevel() + + return super.getLastFoodLevel() + } + + override fun getExhaustionLevel(): Float { + if (player.matteryPlayer.isAndroid && player.matteryPlayer.androidHasEnergy) + return 0f + + return super.getExhaustionLevel() + } + + override fun getSaturationLevel(): Float { + if (player.matteryPlayer.isAndroid) + return if (player.matteryPlayer.androidHasEnergy) player.matteryPlayer.androidEnergy.batteryLevel.percentage(player.matteryPlayer.androidEnergy.maxBatteryLevel) * PlayerConfig.Food.SOFT_FOOD_LIMIT else 0f + + return super.getSaturationLevel() + } + companion object { const val EXHAUSTION_PER_HUNGER_POINT = 4f } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt index bde1b88f8..2553a6656 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt @@ -436,8 +436,6 @@ class MatteryPlayer(val ply: Player) { private var shouldPlaySound = false private val research = IdentityHashMap() - private var nextDischargeHurt = 20 - private var nextHealTick = 0 /** * This returns if player is an Android or will become one on death/sleep/etc @@ -563,6 +561,9 @@ class MatteryPlayer(val ply: Player) { */ val androidEnergy = BatteryBackedEnergyStorage(ply, syncher, PlayerConfig.ANDROID_MAX_ENERGY, PlayerConfig.ANDROID_MAX_ENERGY, true) + val androidHasEnergy: Boolean + get() = androidEnergy.batteryLevel > Decimal.TEN + /** * [IMatteryEnergyStorage] instance, representing Exopack battery charge */ @@ -584,8 +585,6 @@ class MatteryPlayer(val ply: Player) { savetables.bool(::isExopackCraftingUpgraded, "isExoSuitCraftingUpgraded") savetables.bool(::isExopackEnderAccessInstalled, "isExopackEnderAccessUpgraded") savetables.bool(::acceptExopackChargeFromWirelessCharger) - savetables.int(::nextDischargeHurt) - savetables.int(::nextHealTick) savetables.vector(::lastLiquidPosition) savetables.codec(::lastDimension, ResourceLocation.CODEC) @@ -1213,81 +1212,6 @@ class MatteryPlayer(val ply: Player) { lastLiquidPosition = ply.position } - - val stats = ply.foodData - val fourTimesTheHunger = PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * 4 - - // истощение - if (stats.exhaustionLevel > 0f) { - val extracted = androidEnergy.extractEnergy(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (stats.exhaustionLevel / 4f), false) - stats.setExhaustion(stats.exhaustionLevel - (extracted / PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat() * 4f) - } - - // Обычный голод - while ( - stats.foodLevel < 18 && - androidEnergy.batteryLevel >= fourTimesTheHunger && - androidEnergy.extractEnergyExact(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) - ) { - stats.foodLevel++ - } - - // "поглощение" излишек голода, как при мирном режиме, так и при поедании обычной еды - if (PlayerConfig.REGENERATE_ENERGY) { - while (stats.foodLevel > 18 && androidEnergy.receiveEnergyExact(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT / 2, false)) { - stats.foodLevel-- - } - } else if (ply.level().difficulty != Difficulty.PEACEFUL) { - stats.foodLevel = stats.foodLevel.coerceAtMost(18) - } - - val foodLevel = stats.foodLevel.toFloat() - - // насыщение - if (stats.saturationLevel < foodLevel && androidEnergy.batteryLevel >= fourTimesTheHunger) { - val extracted = androidEnergy.extractEnergy(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (foodLevel - stats.saturationLevel), false) - stats.setSaturation(stats.saturationLevel + (extracted / PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat()) - } - - if (androidEnergy.batteryLevel <= Decimal.TEN && !ply.isCreative && ply.level().difficulty != Difficulty.PEACEFUL) { - if (stats.saturationLevel > 1f) { - if (androidEnergy.receiveEnergyExact(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)) { - stats.setSaturation(stats.saturationLevel - 1f) - } - } else if (stats.saturationLevel > 0f) { - val received = androidEnergy.receiveEnergy(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * stats.saturationLevel, false) - stats.setSaturation(stats.saturationLevel - (received / PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat()) - } else if (stats.foodLevel > 0) { - // так как голод не тикает для андроидов, "умереть с голоду" мы не можем - // но со стороны будет выглядеть как будто мы умираем с голода - if (androidEnergy.receiveEnergyExact(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)) { - stats.foodLevel-- - } - } - - if (androidEnergy.batteryLevel <= Decimal.TEN) { - 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 - - if (ply.isHurt && ply.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { - if (--nextHealTick <= 0) { - nextHealTick = if (ply.level().difficulty == Difficulty.PEACEFUL) 10 else PlayerConfig.TIME_BETWEEN_NATURAL_REGENERATION - ply.heal(1f) - } - } else { - nextHealTick = if (ply.level().difficulty == Difficulty.PEACEFUL) 10 else PlayerConfig.TIME_BETWEEN_NATURAL_REGENERATION - } - } } for (feature in featureMap.values) { From b23bda2f6a2b49d9cc0f4f1768dc72d1fb294572 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Mar 2025 10:54:08 +0700 Subject: [PATCH 08/46] Move android package to player package --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 2 +- .../mc/otm/datagen/ResearchData.kt | 6 +- .../datagen/lang/MatteryLanguageProvider.kt | 4 +- .../mc/otm/OverdriveThatMatters.kt | 12 +-- .../mc/otm/client/AndroidAbilityKeyMapping.kt | 2 +- .../mc/otm/client/AndroidMenuKeyMapping.kt | 4 +- .../mc/otm/client/ClientEventHandler.kt | 2 +- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 2 +- .../screen/tech/AndroidStationScreen.kt | 6 +- .../mc/otm/network/AndroidPackets.kt | 10 +-- .../mc/otm/network/NetworkPackets.kt | 4 +- .../mc/otm/player/MatteryPlayer.kt | 16 ++-- .../android/AndroidActiveFeature.kt | 2 +- .../{ => player}/android/AndroidFeature.kt | 2 +- .../android/AndroidFeatureType.kt | 2 +- .../{ => player}/android/AndroidResearch.kt | 2 +- .../android/AndroidResearchDataProvider.kt | 2 +- .../android/AndroidResearchDescription.kt | 74 +++++++++++++++---- .../android/AndroidResearchManager.kt | 7 +- .../android/AndroidResearchResult.kt | 13 ++-- .../android/AndroidResearchType.kt | 6 +- .../android/AndroidSwitchableFeature.kt | 2 +- .../android/feature/AttackBoostFeature.kt | 4 +- .../android/feature/EnderTeleporterFeature.kt | 4 +- .../android/feature/ExtendedReachFeature.kt | 4 +- .../android/feature/FallDampenersFeature.kt | 4 +- .../android/feature/ItemMagnetFeature.kt | 9 ++- .../android/feature/JumpBoostFeature.kt | 4 +- .../feature/LimbOverclockingFeature.kt | 6 +- .../android/feature/NanobotsArmorFeature.kt | 4 +- .../feature/NanobotsRegenerationFeature.kt | 4 +- .../android/feature/NightVisionFeature.kt | 4 +- .../android/feature/ShockwaveFeature.kt | 4 +- .../android/feature/StepAssistFeature.kt | 4 +- .../android/feature/SwimBoostersFeature.kt | 4 +- .../dbotthepony/mc/otm/registry/MRegistry.kt | 6 +- .../mc/otm/registry/game/AndroidFeatures.kt | 18 ++++- .../mc/otm/server/command/AndroidCommand.kt | 4 +- .../server/command/AndroidResearchArgument.kt | 4 +- .../mc/otm/triggers/AndroidResearchTrigger.kt | 2 +- 40 files changed, 165 insertions(+), 110 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/AndroidActiveFeature.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/AndroidFeature.kt (97%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/AndroidFeatureType.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/AndroidResearch.kt (99%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/AndroidResearchDataProvider.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/AndroidResearchDescription.kt (68%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/AndroidResearchManager.kt (97%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/AndroidResearchResult.kt (94%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/AndroidResearchType.kt (99%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/AndroidSwitchableFeature.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/feature/AttackBoostFeature.kt (89%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/feature/EnderTeleporterFeature.kt (99%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/feature/ExtendedReachFeature.kt (89%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/feature/FallDampenersFeature.kt (91%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/feature/ItemMagnetFeature.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/feature/JumpBoostFeature.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/feature/LimbOverclockingFeature.kt (91%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/feature/NanobotsArmorFeature.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/feature/NanobotsRegenerationFeature.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/feature/NightVisionFeature.kt (92%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/feature/ShockwaveFeature.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/feature/StepAssistFeature.kt (93%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => player}/android/feature/SwimBoostersFeature.kt (92%) 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 396d3f04d..52fb18559 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -23,7 +23,7 @@ import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider import net.neoforged.neoforge.data.event.GatherDataEvent import net.neoforged.neoforge.registries.NeoForgeRegistries import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.android.AndroidResearchDataProvider +import ru.dbotthepony.mc.otm.player.android.AndroidResearchDataProvider import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth import ru.dbotthepony.mc.otm.core.util.WriteOnce 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 9032c063f..387c7a582 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt @@ -4,9 +4,9 @@ import net.minecraft.tags.ItemTags import net.minecraft.world.item.Items import net.neoforged.neoforge.common.Tags import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.android.AndroidResearchDescriptions -import ru.dbotthepony.mc.otm.android.AndroidResearchResults -import ru.dbotthepony.mc.otm.android.AndroidResearchType +import ru.dbotthepony.mc.otm.player.android.AndroidResearchDescriptions +import ru.dbotthepony.mc.otm.player.android.AndroidResearchResults +import ru.dbotthepony.mc.otm.player.android.AndroidResearchType import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent 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 a92f5f2bf..7aabd86cc 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 @@ -15,8 +15,8 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.Block import net.neoforged.neoforge.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.player.android.AndroidFeatureType +import ru.dbotthepony.mc.otm.player.android.AndroidResearchType import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt index b9c7345e2..dd23eeaef 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt @@ -6,12 +6,12 @@ import net.neoforged.bus.api.EventPriority import net.neoforged.fml.common.Mod import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent -import ru.dbotthepony.mc.otm.android.AndroidResearchDescription -import ru.dbotthepony.mc.otm.android.AndroidResearchDescriptions -import ru.dbotthepony.mc.otm.android.AndroidResearchManager -import ru.dbotthepony.mc.otm.android.AndroidResearchResult -import ru.dbotthepony.mc.otm.android.AndroidResearchResults -import ru.dbotthepony.mc.otm.android.feature.EnderTeleporterFeature +import ru.dbotthepony.mc.otm.player.android.AndroidResearchDescription +import ru.dbotthepony.mc.otm.player.android.AndroidResearchDescriptions +import ru.dbotthepony.mc.otm.player.android.AndroidResearchManager +import ru.dbotthepony.mc.otm.player.android.AndroidResearchResult +import ru.dbotthepony.mc.otm.player.android.AndroidResearchResults +import ru.dbotthepony.mc.otm.player.android.feature.EnderTeleporterFeature import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity import ru.dbotthepony.mc.otm.player.MatteryPlayer 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 2cb90d1a1..8218c4dd3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt @@ -8,7 +8,7 @@ import net.neoforged.neoforge.client.event.RenderLevelStageEvent import net.neoforged.neoforge.client.settings.KeyConflictContext import net.neoforged.neoforge.network.PacketDistributor import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.android.AndroidActiveFeature +import ru.dbotthepony.mc.otm.player.android.AndroidActiveFeature import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.Widgets18 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 5b6b2065e..70144d851 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt @@ -11,8 +11,8 @@ import net.neoforged.neoforge.client.event.RenderGuiEvent import net.neoforged.neoforge.client.settings.KeyConflictContext import net.neoforged.neoforge.network.PacketDistributor 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.player.android.AndroidFeature +import ru.dbotthepony.mc.otm.player.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.RenderGravity 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 fa0975202..e6b4e9539 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 net.neoforged.neoforge.client.event.ScreenEvent import net.neoforged.neoforge.event.entity.player.ItemTooltipEvent import net.neoforged.neoforge.network.PacketDistributor import ru.dbotthepony.mc.otm.config.ClientConfig -import ru.dbotthepony.mc.otm.android.feature.JumpBoostFeature +import ru.dbotthepony.mc.otm.player.android.feature.JumpBoostFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.render.UVWindingOrder 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 20e18e1c6..e414af87d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -23,7 +23,7 @@ import net.neoforged.neoforge.client.event.RenderGuiLayerEvent import net.neoforged.neoforge.client.event.ScreenEvent import net.neoforged.neoforge.client.gui.VanillaGuiLayers import net.neoforged.neoforge.common.ItemAbilities -import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature +import ru.dbotthepony.mc.otm.player.android.feature.NanobotsArmorFeature import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.player.matteryPlayer 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 fee98d5b6..f6edd683a 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 @@ -11,9 +11,9 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack import net.neoforged.neoforge.network.PacketDistributor 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.player.android.AndroidResearch +import ru.dbotthepony.mc.otm.player.android.AndroidResearchManager +import ru.dbotthepony.mc.otm.player.android.AndroidResearchType import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.client.CursorType import ru.dbotthepony.mc.otm.client.render.MGUIGraphics diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/AndroidPackets.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/AndroidPackets.kt index 74a49b8e6..b05ef757b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/AndroidPackets.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/AndroidPackets.kt @@ -10,11 +10,11 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.sounds.SoundSource import net.neoforged.neoforge.network.handling.IPayloadContext import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.android.AndroidActiveFeature -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.player.android.AndroidActiveFeature +import ru.dbotthepony.mc.otm.player.android.AndroidFeatureType +import ru.dbotthepony.mc.otm.player.android.AndroidResearchManager +import ru.dbotthepony.mc.otm.player.android.AndroidResearchType +import ru.dbotthepony.mc.otm.player.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.MatteryGUI diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/NetworkPackets.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/NetworkPackets.kt index a44f72a04..1dcb38afa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/NetworkPackets.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/NetworkPackets.kt @@ -2,8 +2,8 @@ package ru.dbotthepony.mc.otm.network import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent import net.neoforged.neoforge.network.registration.HandlerThread -import ru.dbotthepony.mc.otm.android.AndroidResearchManager -import ru.dbotthepony.mc.otm.android.feature.ItemEntityDataPacket +import ru.dbotthepony.mc.otm.player.android.AndroidResearchManager +import ru.dbotthepony.mc.otm.player.android.feature.ItemEntityDataPacket import ru.dbotthepony.mc.otm.compat.vanilla.InventoryScrollPacket import ru.dbotthepony.mc.otm.data.FlywheelMaterials import ru.dbotthepony.mc.otm.item.QuantumBatteryItem diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt index 2553a6656..a8a906d5f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt @@ -20,10 +20,7 @@ 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 -import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.effect.MobEffects import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.boss.wither.WitherBoss @@ -36,7 +33,6 @@ 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.crafting.SingleRecipeInput -import net.minecraft.world.level.GameRules import net.minecraft.world.level.Level import net.minecraft.world.phys.Vec3 import net.neoforged.bus.api.Event @@ -60,11 +56,11 @@ import ru.dbotthepony.kommons.util.getValue import ru.dbotthepony.kommons.util.setValue import ru.dbotthepony.kommons.util.value 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.player.android.AndroidFeature +import ru.dbotthepony.mc.otm.player.android.AndroidFeatureType +import ru.dbotthepony.mc.otm.player.android.AndroidResearch +import ru.dbotthepony.mc.otm.player.android.AndroidResearchManager +import ru.dbotthepony.mc.otm.player.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 @@ -74,8 +70,6 @@ import ru.dbotthepony.mc.otm.capability.energy 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.capability.receiveEnergy import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.config.PlayerConfig diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidActiveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidActiveFeature.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidActiveFeature.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidActiveFeature.kt index 230a0cd47..348be4672 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidActiveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidActiveFeature.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.android +package ru.dbotthepony.mc.otm.player.android import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.Camera diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidFeature.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidFeature.kt index 958e2ae6f..b225be0e1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidFeature.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.android +package ru.dbotthepony.mc.otm.player.android import net.minecraft.core.HolderLookup import net.minecraft.nbt.CompoundTag diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidFeatureType.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidFeatureType.kt index d01adc685..9fcc9be5c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidFeatureType.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.android +package ru.dbotthepony.mc.otm.player.android import net.minecraft.network.chat.Component import net.minecraft.network.chat.ComponentContents diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearch.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearch.kt index 3954b9f2e..8e3675772 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearch.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.android +package ru.dbotthepony.mc.otm.player.android import net.minecraft.ChatFormatting import net.minecraft.core.HolderLookup diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchDataProvider.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchDataProvider.kt index 1ca529af2..492295d78 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchDataProvider.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.android +package ru.dbotthepony.mc.otm.player.android import com.google.gson.JsonObject import it.unimi.dsi.fastutil.objects.ObjectArraySet diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchDescription.kt similarity index 68% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchDescription.kt index 1a53c7e37..ac201aa1a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchDescription.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.android +package ru.dbotthepony.mc.otm.player.android import com.mojang.serialization.Codec import com.mojang.serialization.MapCodec @@ -29,35 +29,76 @@ object AndroidResearchDescriptions { val ENDER_TELEPORTER: AndroidResearchDescription.Singleton by registrar.register("ender_teleporter") { AndroidResearchDescription.singleton { - TranslatableComponent("otm.gui.power_cost_per_use", PlayerConfig.EnderTeleporter.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW)) } + TranslatableComponent( + "otm.gui.power_cost_per_use", + PlayerConfig.EnderTeleporter.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy() + .withStyle(ChatFormatting.YELLOW) + ) + } } val FALL_DAMPENERS: AndroidResearchDescription.Leveled by registrar.register("fall_dampeners") { AndroidResearchDescription.Leveled { _, list, level -> - list.add(TranslatableComponent("otm.fall_dampeners.description", - TextComponent("%.1f".format((PlayerConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_P * level).toFloat().coerceIn(0f, 1f) * 100f)).withStyle(ChatFormatting.YELLOW), - TextComponent("%.1f".format((PlayerConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_F * level).toFloat())).withStyle(ChatFormatting.YELLOW), - )) } + list.add( + TranslatableComponent( + "otm.fall_dampeners.description", + TextComponent( + "%.1f".format( + (PlayerConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_P * level).toFloat().coerceIn(0f, 1f) * 100f + ) + ).withStyle(ChatFormatting.YELLOW), + TextComponent("%.1f".format((PlayerConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_F * level).toFloat())).withStyle( + ChatFormatting.YELLOW + ), + ) + ) + } } 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(PlayerConfig.SWIM_BOOSTERS * (1 + level) * 100.0)).withStyle(ChatFormatting.YELLOW) - )) } + list.add( + TranslatableComponent( + "android_research.overdrive_that_matters.swim_boosters.description", + TextComponent("%.1f".format(PlayerConfig.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", PlayerConfig.Magnet.POWER_DRAW.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW)) } + AndroidResearchDescription.singleton { + TranslatableComponent( + "otm.gui.power_cost_per_tick", + PlayerConfig.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", PlayerConfig.JumpBoost.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW)) } + AndroidResearchDescription.singleton { + TranslatableComponent( + "otm.gui.power_cost_per_use", + PlayerConfig.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", PlayerConfig.Shockwave.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW)) } + AndroidResearchDescription.singleton { + TranslatableComponent( + "otm.gui.power_cost_per_use", + PlayerConfig.Shockwave.ENERGY_COST.formatPower( + formatAsReadable = ShiftPressedCond + ).copy().withStyle(ChatFormatting.YELLOW) + ) + } } } @@ -78,7 +119,8 @@ interface AndroidResearchDescription { get() = this } - class Leveled(val callback: (research: AndroidResearch, lines: MutableList, level: Int) -> Unit) : Type { + 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) @@ -90,7 +132,7 @@ interface AndroidResearchDescription { override val codec: MapCodec by lazy { RecordCodecBuilder.mapCodec { - it.group(Codec.INT.fieldOf("level").forGetter(Instance::level)).apply(it, ::Instance) + it.group(Codec.INT.fieldOf("level").forGetter(Instance::level)).apply(it, Leveled::Instance) } } } @@ -138,7 +180,7 @@ object PlainAndroidResearchDescription : AndroidResearchDescription.Type(ResourceLocation(OverdriveThatMatters.MOD_ID, "research_sync")) - val SYNC_CODEC: StreamCodec = StreamCodec.ofMember(SyncPacket::write, ::readSyncPacket) + val SYNC_CODEC: StreamCodec = StreamCodec.ofMember( + SyncPacket::write, + AndroidResearchManager::readSyncPacket + ) class SyncPacket(val collection: Collection) : CustomPacketPayload { fun write(buff: FriendlyByteBuf) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchResult.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchResult.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchResult.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchResult.kt index ac67e499e..41043c82d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchResult.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchResult.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.android +package ru.dbotthepony.mc.otm.player.android import com.mojang.serialization.Codec import com.mojang.serialization.MapCodec @@ -16,8 +16,8 @@ object AndroidResearchResults { private val registrar = MDeferredRegister(AndroidResearchResult.registryKey, OverdriveThatMatters.MOD_ID) init { - registrar.register("feature") { AndroidResearchResult.Feature.Companion } - registrar.register("feature_level") { AndroidResearchResult.FeatureLevel.Companion } + registrar.register("feature") { AndroidResearchResult.Feature } + registrar.register("feature_level") { AndroidResearchResult.FeatureLevel } } private object NanobotsArmorStrength : AndroidResearchResult.Singleton { @@ -90,7 +90,7 @@ interface AndroidResearchResult { it.group( ResourceLocation.CODEC.fieldOf("id").forGetter(Feature::id), Codec.BOOL.optionalFieldOf("optional", false).forGetter(Feature::optional) - ).apply(it, ::Feature) + ).apply(it, AndroidResearchResult::Feature) } } } @@ -99,7 +99,8 @@ interface AndroidResearchResult { /** * 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 { + class FeatureLevel(val id: ResourceLocation, val optional: Boolean = false, val levels: Int = 1) : + AndroidResearchResult { val feature = MRegistry.ANDROID_FEATURES.get(id) ?: if (optional) null else throw NoSuchElementException("Unknown android feature $id") override val type: Type<*> @@ -132,7 +133,7 @@ interface AndroidResearchResult { 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) + ).apply(it, AndroidResearchResult::FeatureLevel) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchType.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchType.kt index f7e2cc739..e7fb141cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchType.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.android +package ru.dbotthepony.mc.otm.player.android import com.google.common.collect.ImmutableList import com.google.gson.JsonObject @@ -131,10 +131,10 @@ class AndroidResearchType( it.group( ResourceLocation.CODEC.fieldOf("id").forGetter(Reference::id), Codec.BOOL.optionalFieldOf("optional", false).forGetter(Reference::optional) - ).apply(it, ::Reference) + ).apply(it, AndroidResearchType::Reference) }) .xmap( - { c -> c.map(::Reference, Function.identity()) }, + { c -> c.map(AndroidResearchType::Reference, Function.identity()) }, { c -> if (c.optional) Either.right(c) else Either.left(c.id) } ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidSwitchableFeature.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidSwitchableFeature.kt index df6ea10af..04a67138c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidSwitchableFeature.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.android +package ru.dbotthepony.mc.otm.player.android import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.core.HolderLookup diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/AttackBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/AttackBoostFeature.kt similarity index 89% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/AttackBoostFeature.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/AttackBoostFeature.kt index d70658560..c37ae67b8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/AttackBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/AttackBoostFeature.kt @@ -1,9 +1,9 @@ -package ru.dbotthepony.mc.otm.android.feature +package ru.dbotthepony.mc.otm.player.android.feature import net.minecraft.world.entity.ai.attributes.AttributeModifier import net.minecraft.world.entity.ai.attributes.Attributes import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.android.AndroidFeature +import ru.dbotthepony.mc.otm.player.android.AndroidFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/EnderTeleporterFeature.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/EnderTeleporterFeature.kt index 35bad8f25..807d461b1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/EnderTeleporterFeature.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.android.feature +package ru.dbotthepony.mc.otm.player.android.feature import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack @@ -25,7 +25,7 @@ import net.neoforged.neoforge.event.entity.living.LivingDeathEvent import ru.dbotthepony.kommons.math.RGBAColor 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.player.android.AndroidActiveFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.player.matteryPlayer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ExtendedReachFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/ExtendedReachFeature.kt similarity index 89% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ExtendedReachFeature.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/ExtendedReachFeature.kt index c816e044e..7c80cab46 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ExtendedReachFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/ExtendedReachFeature.kt @@ -1,9 +1,9 @@ -package ru.dbotthepony.mc.otm.android.feature +package ru.dbotthepony.mc.otm.player.android.feature import net.minecraft.world.entity.ai.attributes.AttributeModifier import net.minecraft.world.entity.ai.attributes.Attributes import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.android.AndroidFeature +import ru.dbotthepony.mc.otm.player.android.AndroidFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/FallDampenersFeature.kt similarity index 91% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/FallDampenersFeature.kt index 0ab545303..9e2cc4ea2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/FallDampenersFeature.kt @@ -1,8 +1,8 @@ -package ru.dbotthepony.mc.otm.android.feature +package ru.dbotthepony.mc.otm.player.android.feature import net.minecraft.server.level.ServerPlayer import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent -import ru.dbotthepony.mc.otm.android.AndroidFeature +import ru.dbotthepony.mc.otm.player.android.AndroidFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.config.PlayerConfig import ru.dbotthepony.mc.otm.core.isFall diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/ItemMagnetFeature.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/ItemMagnetFeature.kt index 679f8f767..abd1d7f60 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/ItemMagnetFeature.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.android.feature +package ru.dbotthepony.mc.otm.player.android.feature import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.network.FriendlyByteBuf @@ -12,7 +12,7 @@ import net.neoforged.neoforge.network.handling.IPayloadContext import ru.dbotthepony.kommons.math.RGBAColor import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.config.PlayerConfig -import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature +import ru.dbotthepony.mc.otm.player.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.client.render.MGUIGraphics @@ -60,7 +60,10 @@ class ItemEntityDataPacket(val itemUUID: Int, val owner: UUID? = null, val age: companion object { val TYPE = CustomPacketPayload.Type(ResourceLocation(OverdriveThatMatters.MOD_ID, "item_entity_data")) - val CODEC: StreamCodec = StreamCodec.ofMember(ItemEntityDataPacket::write, ::read) + val CODEC: StreamCodec = StreamCodec.ofMember( + ItemEntityDataPacket::write, + Companion::read + ) fun read(buff: FriendlyByteBuf): ItemEntityDataPacket { return ItemEntityDataPacket(buff.readVarInt(), if (buff.readBoolean()) buff.readUUID() else null, buff.readVarInt(), buff.readVarInt(), buff.readBoolean()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/JumpBoostFeature.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/JumpBoostFeature.kt index 073327eda..c53c7742a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/JumpBoostFeature.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.android.feature +package ru.dbotthepony.mc.otm.player.android.feature import net.minecraft.server.level.ServerPlayer import net.minecraft.sounds.SoundSource @@ -6,7 +6,7 @@ import net.neoforged.neoforge.network.PacketDistributor import ru.dbotthepony.kommons.math.RGBAColor import ru.dbotthepony.kommons.util.getValue import ru.dbotthepony.kommons.util.setValue -import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature +import ru.dbotthepony.mc.otm.player.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.client.render.MGUIGraphics diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/LimbOverclockingFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/LimbOverclockingFeature.kt similarity index 91% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/LimbOverclockingFeature.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/LimbOverclockingFeature.kt index 061d5302e..66c5cde75 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/LimbOverclockingFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/LimbOverclockingFeature.kt @@ -1,11 +1,11 @@ -package ru.dbotthepony.mc.otm.android.feature +package ru.dbotthepony.mc.otm.player.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.OverdriveThatMatters -import ru.dbotthepony.mc.otm.android.AndroidFeature +import ru.dbotthepony.mc.otm.player.android.AndroidFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.core.ResourceLocation @@ -17,7 +17,7 @@ class LimbOverclockingFeature(android: MatteryPlayer) : AndroidFeature(AndroidFe if (speed != null) { speed.removeModifier(MODIFIER_ID) - speed.addPermanentModifier(AttributeModifier(MODIFIER_ID,(level + 1) * 0.08, AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL)) + speed.addPermanentModifier(AttributeModifier(MODIFIER_ID, (level + 1) * 0.08, AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL)) } val attackSpeed = ply.getAttribute(Attributes.ATTACK_SPEED) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/NanobotsArmorFeature.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/NanobotsArmorFeature.kt index d80ce2a14..732677573 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/NanobotsArmorFeature.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.android.feature +package ru.dbotthepony.mc.otm.player.android.feature import net.minecraft.core.HolderLookup import net.minecraft.nbt.CompoundTag @@ -7,7 +7,7 @@ import net.minecraft.tags.DamageTypeTags import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent import ru.dbotthepony.kommons.util.getValue import ru.dbotthepony.kommons.util.setValue -import ru.dbotthepony.mc.otm.android.AndroidFeature +import ru.dbotthepony.mc.otm.player.android.AndroidFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.core.isBypassArmor diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/NanobotsRegenerationFeature.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/NanobotsRegenerationFeature.kt index 23a06c150..1e3817629 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/NanobotsRegenerationFeature.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.android.feature +package ru.dbotthepony.mc.otm.player.android.feature import net.minecraft.core.HolderLookup import net.minecraft.nbt.CompoundTag @@ -6,7 +6,7 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.level.GameRules import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent import ru.dbotthepony.mc.otm.config.PlayerConfig -import ru.dbotthepony.mc.otm.android.AndroidFeature +import ru.dbotthepony.mc.otm.player.android.AndroidFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.registry.game.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/player/android/feature/NightVisionFeature.kt similarity index 92% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/NightVisionFeature.kt index c4c3d9df4..4277aced7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/NightVisionFeature.kt @@ -1,9 +1,9 @@ -package ru.dbotthepony.mc.otm.android.feature +package ru.dbotthepony.mc.otm.player.android.feature import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.effect.MobEffects import ru.dbotthepony.kommons.math.RGBAColor -import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature +import ru.dbotthepony.mc.otm.player.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.client.render.MGUIGraphics diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/ShockwaveFeature.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/ShockwaveFeature.kt index a78b9fe14..a7d3eb6d6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/ShockwaveFeature.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.android.feature +package ru.dbotthepony.mc.otm.player.android.feature import it.unimi.dsi.fastutil.objects.ReferenceArraySet import net.minecraft.server.level.ServerPlayer @@ -7,7 +7,7 @@ import net.minecraft.world.entity.Entity import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.monster.warden.Warden import net.neoforged.neoforge.network.PacketDistributor -import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature +import ru.dbotthepony.mc.otm.player.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.client.render.MGUIGraphics diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/StepAssistFeature.kt similarity index 93% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/StepAssistFeature.kt index 92d048b78..08cb9cc6a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/StepAssistFeature.kt @@ -1,8 +1,8 @@ -package ru.dbotthepony.mc.otm.android.feature +package ru.dbotthepony.mc.otm.player.android.feature import net.minecraft.world.entity.ai.attributes.AttributeModifier import net.minecraft.world.entity.ai.attributes.Attributes -import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature +import ru.dbotthepony.mc.otm.player.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/SwimBoostersFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/SwimBoostersFeature.kt similarity index 92% rename from src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/SwimBoostersFeature.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/SwimBoostersFeature.kt index 4f9c16ceb..2cd1a933e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/SwimBoostersFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/SwimBoostersFeature.kt @@ -1,8 +1,8 @@ -package ru.dbotthepony.mc.otm.android.feature +package ru.dbotthepony.mc.otm.player.android.feature import net.minecraft.world.entity.ai.attributes.AttributeModifier import net.neoforged.neoforge.common.NeoForgeMod -import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature +import ru.dbotthepony.mc.otm.player.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.player.MatteryPlayer import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons 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 0cf69e5f3..e117ad120 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -29,9 +29,9 @@ import net.neoforged.neoforge.event.ModifyDefaultComponentsEvent import net.neoforged.neoforge.registries.RegisterEvent import ru.dbotthepony.kommons.math.RGBAColor import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.android.AndroidFeatureType -import ru.dbotthepony.mc.otm.android.feature.EnderTeleporterFeature -import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature +import ru.dbotthepony.mc.otm.player.android.AndroidFeatureType +import ru.dbotthepony.mc.otm.player.android.feature.EnderTeleporterFeature +import ru.dbotthepony.mc.otm.player.android.feature.NanobotsArmorFeature import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.decorative.ComputerTerminalBlock import ru.dbotthepony.mc.otm.block.decorative.StarChairBlock diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/AndroidFeatures.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/AndroidFeatures.kt index 43dbc2b22..f3ad0df38 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/AndroidFeatures.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/AndroidFeatures.kt @@ -1,9 +1,21 @@ package ru.dbotthepony.mc.otm.registry.game import net.neoforged.bus.api.IEventBus -import ru.dbotthepony.mc.otm.android.AndroidFeatureType -import ru.dbotthepony.mc.otm.android.DummyAndroidFeature -import ru.dbotthepony.mc.otm.android.feature.* +import ru.dbotthepony.mc.otm.player.android.AndroidFeatureType +import ru.dbotthepony.mc.otm.player.android.DummyAndroidFeature +import ru.dbotthepony.mc.otm.player.android.feature.AttackBoostFeature +import ru.dbotthepony.mc.otm.player.android.feature.EnderTeleporterFeature +import ru.dbotthepony.mc.otm.player.android.feature.ExtendedReachFeature +import ru.dbotthepony.mc.otm.player.android.feature.FallDampenersFeature +import ru.dbotthepony.mc.otm.player.android.feature.ItemMagnetFeature +import ru.dbotthepony.mc.otm.player.android.feature.JumpBoostFeature +import ru.dbotthepony.mc.otm.player.android.feature.LimbOverclockingFeature +import ru.dbotthepony.mc.otm.player.android.feature.NanobotsArmorFeature +import ru.dbotthepony.mc.otm.player.android.feature.NanobotsRegenerationFeature +import ru.dbotthepony.mc.otm.player.android.feature.NightVisionFeature +import ru.dbotthepony.mc.otm.player.android.feature.ShockwaveFeature +import ru.dbotthepony.mc.otm.player.android.feature.StepAssistFeature +import ru.dbotthepony.mc.otm.player.android.feature.SwimBoostersFeature import ru.dbotthepony.mc.otm.registry.MDeferredRegister import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.registry.MRegistry diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/AndroidCommand.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/AndroidCommand.kt index f56e583a5..08e2a5df2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/AndroidCommand.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/AndroidCommand.kt @@ -4,8 +4,8 @@ import net.minecraft.commands.Commands import net.minecraft.commands.arguments.EntityArgument import net.minecraft.world.entity.player.Player import net.neoforged.neoforge.event.RegisterCommandsEvent -import ru.dbotthepony.mc.otm.android.AndroidResearchManager -import ru.dbotthepony.mc.otm.android.AndroidResearchType +import ru.dbotthepony.mc.otm.player.android.AndroidResearchManager +import ru.dbotthepony.mc.otm.player.android.AndroidResearchType import ru.dbotthepony.mc.otm.player.matteryPlayer object AndroidCommand { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/AndroidResearchArgument.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/AndroidResearchArgument.kt index 16b9cebde..80a58b0c9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/AndroidResearchArgument.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/server/command/AndroidResearchArgument.kt @@ -8,8 +8,8 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.SharedSuggestionProvider import net.minecraft.resources.ResourceLocation -import ru.dbotthepony.mc.otm.android.AndroidResearchManager -import ru.dbotthepony.mc.otm.android.AndroidResearchType +import ru.dbotthepony.mc.otm.player.android.AndroidResearchManager +import ru.dbotthepony.mc.otm.player.android.AndroidResearchType import java.util.concurrent.CompletableFuture class AndroidResearchArgument : ArgumentType { 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 a761cc0bb..8b71b4b85 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt @@ -6,7 +6,7 @@ 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.player.android.AndroidResearchType import ru.dbotthepony.mc.otm.core.ResourceLocation import java.util.* import java.util.function.Predicate From 922f94b9de82f2646ad9d6e9b9a02a1920894233 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Mar 2025 11:02:08 +0700 Subject: [PATCH 09/46] e --- src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt index 7bad9ab1c..d145a42be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt @@ -190,7 +190,7 @@ object PlayerConfig : AbstractConfig("player") { val EXHAUSTION_LIMIT: Double by builder .comment("Controls technical aspect how much 'exhaustion' player can accumulate") .comment("This should not be confused with how much 'exhaustion' is considered as 1 hunger point") - .comment("Usually, this should not be changed, since it is a very technical detail") + .comment("Usually, this should not be changed, since it is a very technical detail;") .comment("but if you have a mod installed which easily hits this limit (and somehow hunger system can't keep up,)") .comment("e.g. it pushes exhaustion over its limit in one call), you can increase this value") .defineInRange("EXHAUSTION_LIMIT", 40.0, 4.0, Float.MAX_VALUE.toDouble() - 1.0) From d10b1b4ee1a820717f44f442f9e51be3024766bd Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Mar 2025 11:21:08 +0700 Subject: [PATCH 10/46] Aeugh --- .../mc/otm/player/android/AndroidResearchDescription.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchDescription.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchDescription.kt index ac201aa1a..2afc8d9dc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchDescription.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchDescription.kt @@ -119,8 +119,7 @@ interface AndroidResearchDescription { get() = this } - class Leveled(val callback: (research: AndroidResearch, lines: MutableList, level: Int) -> Unit) : - Type { + 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) @@ -132,7 +131,7 @@ interface AndroidResearchDescription { override val codec: MapCodec by lazy { RecordCodecBuilder.mapCodec { - it.group(Codec.INT.fieldOf("level").forGetter(Instance::level)).apply(it, Leveled::Instance) + it.group(Codec.INT.fieldOf("level").forGetter(Instance::level)).apply(it, ::Instance) } } } From e06928a4b54aae4e9832acf11b0a243fd847b355 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Mar 2025 11:24:58 +0700 Subject: [PATCH 11/46] Update mixin signature --- src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java index c6f691361..19a9c6a17 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java @@ -97,7 +97,7 @@ public abstract class MixinPlayer implements IMatteryPlayer { method = "", at = @At("TAIL") ) - private void ctorMix() { + private void ctorMix(Level level, BlockPos pos, float yRot, GameProfile gameProfile, CallbackInfo info) { foodData = new MatteryFoodData(otmSelf()); } } From 5d8f2d5a4a8644052c4639be8e8efd8fe1e306fe Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Mar 2025 12:04:16 +0700 Subject: [PATCH 12/46] Add REGENERATE_ENERGY_EFFICIENCY_FOOD and REGENERATE_ENERGY_EFFICIENCY_SATURATION --- .../kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt | 8 ++++++++ .../ru/dbotthepony/mc/otm/player/MatteryFoodData.kt | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt index d145a42be..b8be2c4c8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt @@ -14,6 +14,14 @@ object PlayerConfig : AbstractConfig("player") { .comment("And also whenever to regenerate energy while in peaceful") .define("REGENERATE_ENERGY", true) + val REGENERATE_ENERGY_EFFICIENCY_FOOD: Double by builder + .comment("How much % of food points to convert to energy") + .defineInRange("REGENERATE_ENERGY_EFFICIENCY_FOOD", 0.75, 0.0) + + val REGENERATE_ENERGY_EFFICIENCY_SATURATION: Double by builder + .comment("How much % of food saturation points to convert to energy") + .defineInRange("REGENERATE_ENERGY_EFFICIENCY_SATURATION", 0.4, 0.0) + val REGENERATE_ENERGY_IN_PEACEFUL: Boolean by builder .comment("Regenerate energy while in peaceful") .comment("This is disabled by default because this is easily exploitable") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt index 279438107..1ffbc6b74 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt @@ -25,7 +25,8 @@ import kotlin.math.roundToInt class MatteryFoodData(private var player: Player) : FoodData() { private fun add(foodLevel: Int, saturation: Float) { if (player.matteryPlayer.isAndroid && PlayerConfig.REGENERATE_ENERGY) { - energyToDrain -= PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * foodLevel + PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * saturation + energyToDrain -= PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * foodLevel * PlayerConfig.REGENERATE_ENERGY_EFFICIENCY_FOOD + energyToDrain -= PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * saturation.coerceAtMost(PlayerConfig.Food.SOFT_FOOD_LIMIT.toFloat()) * PlayerConfig.REGENERATE_ENERGY_EFFICIENCY_SATURATION } else if (!player.matteryPlayer.isAndroid) { this.foodLevel = min(this.foodLevel + foodLevel, PlayerConfig.Food.HARD_FOOD_LIMIT) this.saturationLevel = min(this.saturationLevel + saturation, this.foodLevel + PlayerConfig.Food.OVERSATURATION_LIMIT.toFloat()).coerceAtLeast(0f) From ca37b4959fd6f0ce8bd9771fa29ccf7976100354 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Mar 2025 17:36:55 +0700 Subject: [PATCH 13/46] Bring back old behavior where exhaustion is immediately nullified by energy buffer on Androids --- .../mc/otm/player/MatteryFoodData.kt | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt index 1ffbc6b74..b460cd7de 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt @@ -69,21 +69,20 @@ class MatteryFoodData(private var player: Player) : FoodData() { private var energyToDrain = Decimal.ZERO private fun tickExhaustion() { - if (exhaustionLevel >= EXHAUSTION_PER_HUNGER_POINT) { + if (player.matteryPlayer.isAndroid && exhaustionLevel > 0f) { + energyToDrain += PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (exhaustionLevel / EXHAUSTION_PER_HUNGER_POINT) + exhaustionLevel = 0f + } else if (exhaustionLevel >= EXHAUSTION_PER_HUNGER_POINT) { var points = (exhaustionLevel / EXHAUSTION_PER_HUNGER_POINT).toInt() exhaustionLevel %= EXHAUSTION_PER_HUNGER_POINT - if (player.matteryPlayer.isAndroid) { - energyToDrain += PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * points - } else { - if (saturationLevel > 0f) { - val satisfied = min(saturationLevel.roundToInt(), points) - points -= satisfied - saturationLevel -= satisfied - } - - foodLevel = max(0, foodLevel - points) + if (saturationLevel > 0f) { + val satisfied = min(saturationLevel.roundToInt(), points) + points -= satisfied + saturationLevel -= satisfied } + + foodLevel = max(0, foodLevel - points) } } From 80ff50b937cf537a422250276102111f8b2efbef Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Mar 2025 17:40:16 +0700 Subject: [PATCH 14/46] Nullify excess hunger when eating as android --- .../kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt index b460cd7de..62b9a8e82 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt @@ -110,9 +110,13 @@ class MatteryFoodData(private var player: Player) : FoodData() { if (player.matteryPlayer.isAndroid) { if (energyToDrain > Decimal.ZERO) energyToDrain -= player.matteryPlayer.androidEnergy.extractEnergy(energyToDrain, false) - else if (energyToDrain < Decimal.ZERO) + else if (energyToDrain < Decimal.ZERO) { energyToDrain += player.matteryPlayer.androidEnergy.receiveEnergy(-energyToDrain, false) + if (player.matteryPlayer.androidEnergy.missingPower <= Decimal.ZERO) + energyToDrain = Decimal.ZERO + } + if (player.level().difficulty == Difficulty.PEACEFUL && PlayerConfig.REGENERATE_ENERGY_IN_PEACEFUL) player.matteryPlayer.androidEnergy.receiveEnergy(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) From 579445fbbe46dfe56c1eccf8e6e5848b08890b65 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Mar 2025 17:44:26 +0700 Subject: [PATCH 15/46] Nerf food for androids further --- .../dbotthepony/mc/otm/config/PlayerConfig.kt | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt index b8be2c4c8..c9f907244 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt @@ -16,11 +16,11 @@ object PlayerConfig : AbstractConfig("player") { val REGENERATE_ENERGY_EFFICIENCY_FOOD: Double by builder .comment("How much % of food points to convert to energy") - .defineInRange("REGENERATE_ENERGY_EFFICIENCY_FOOD", 0.75, 0.0) + .defineInRange("REGENERATE_ENERGY_EFFICIENCY_FOOD", 0.4, 0.0) val REGENERATE_ENERGY_EFFICIENCY_SATURATION: Double by builder .comment("How much % of food saturation points to convert to energy") - .defineInRange("REGENERATE_ENERGY_EFFICIENCY_SATURATION", 0.4, 0.0) + .defineInRange("REGENERATE_ENERGY_EFFICIENCY_SATURATION", 0.2, 0.0) val REGENERATE_ENERGY_IN_PEACEFUL: Boolean by builder .comment("Regenerate energy while in peaceful") @@ -39,6 +39,28 @@ object PlayerConfig : AbstractConfig("player") { .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) + 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") + .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 + .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()) + + val SWIM_BOOSTERS: Double by builder + .comment("Increase per level") + .defineInRange("SWIM_BOOSTERS", 0.25, 0.0, Float.MAX_VALUE.toDouble()) + init { builder.pop() } @@ -71,27 +93,6 @@ object PlayerConfig : AbstractConfig("player") { } } - 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") - .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 - .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()) - - 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") From bc5ad7f37be08f95cfd767c7f710b34507a77f21 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Mar 2025 19:47:13 +0700 Subject: [PATCH 16/46] =?UTF-8?q?=D0=BA=D0=B8=D0=BF=D1=8F=D1=82=D0=BE?= =?UTF-8?q?=D1=87=D0=B5=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 64766db67..0687260bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt @@ -83,5 +83,5 @@ object ServerConfig : AbstractConfig("misc") { val WITHER_SKELETON_SWORD_CHANCE: Double by builder .comment("Chance of Wither Skeleton spawning with Withered Steel sword") - .defineInRange("WITHER_SKELETON_HELMET_CHANCE", 0.24, 0.0, 1.0) + .defineInRange("WITHER_SKELETON_SWORD_CHANCE", 0.24, 0.0, 1.0) } From b7b2b8095cc0295d098f9c0adef30e190b935a32 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 15 Mar 2025 10:04:16 +0700 Subject: [PATCH 17/46] Revert "Remove otmRandom" This reverts commit 5a016bef The way OTM uses random generator in its code will quickly cause LCG used in Minecraft to show its bias because LCG in minecraft samples its highest 48 bits, which gives us at best 2^16 period in the lowest bit returned by LCG. Which it doesn't sound bad, it quickly causes RNG become biased the quicker/more it is sampled on each tick, especially considering some may use `level.random.nextInt(chance) == 0` to determine chance of something happening, which will get extremely biased on heavy RNG congested environment If we avoid sampling Level's generator this much, we won't suffer from bias in our own code, as well as avoid biasing other mods this much. The "2^16 period" problem is also might be the reason why Entities get their own instance of RandomSource, and Mob Goals use random exactly the way described above (`nextInt(chance)`), which can and will suffer from bias the moment mob exists in world for more than 2^16 ticks (but actual bias will happen sooner because RNG is not sampled only once per tick, obviously) --- .../dbotthepony/mc/otm/mixin/LevelMixin.java | 19 +++++++++++++++++++ .../mixin/MixinAbstractHurtingProjectile.java | 3 ++- .../entity/blackhole/BlackHoleBlockEntity.kt | 4 ++-- .../BlackHoleGeneratorBlockEntity.kt | 6 +++--- .../block/entity/cable/EnergyCableGraph.kt | 4 ++-- .../decorative/CargoCrateBlockEntity.kt | 4 ++-- .../matter/MatterDecomposerBlockEntity.kt | 4 ++-- .../matter/MatterReconstructorBlockEntity.kt | 4 ++-- .../matter/MatterRecyclerBlockEntity.kt | 4 ++-- .../matter/MatterReplicatorBlockEntity.kt | 4 ++-- .../tech/AbstractPoweredFurnaceBlockEntity.kt | 4 ++-- .../entity/tech/AndroidChargerBlockEntity.kt | 3 ++- .../entity/tech/AndroidStationBlockEntity.kt | 3 ++- .../entity/tech/BatteryBankBlockEntity.kt | 4 ++-- .../entity/tech/EnergyInterfaceBlockEntity.kt | 4 ++-- .../entity/tech/EssenceStorageBlockEntity.kt | 6 +++--- .../entity/tech/PlatePressBlockEntity.kt | 4 ++-- .../dbotthepony/mc/otm/core/IMatteryLevel.kt | 17 +++++++++++++++++ .../mc/otm/entity/MinecartCargoCrate.kt | 4 ++-- .../mc/otm/entity/SpawnModifiers.kt | 6 +++--- .../ru/dbotthepony/mc/otm/item/BatteryItem.kt | 4 ++-- .../item/consumables/EssenceCapsuleItem.kt | 3 ++- .../item/consumables/ImperfectBreadItem.kt | 4 ++-- .../mc/otm/item/tool/ExplosiveHammerItem.kt | 4 ++-- .../mc/otm/item/weapon/EnergySwordItem.kt | 9 +++++---- .../mc/otm/item/weapon/FallingSunItem.kt | 9 +++++---- .../mc/otm/network/MatteryPlayerPackets.kt | 3 ++- .../mc/otm/network/SmokeParticlesPacket.kt | 4 ++-- .../mc/otm/player/MatteryPlayer.kt | 4 ++-- .../android/feature/EnderTeleporterFeature.kt | 7 ++++--- .../overdrive_that_matters.mixins.json | 3 ++- 31 files changed, 105 insertions(+), 60 deletions(-) create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/LevelMixin.java create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/IMatteryLevel.kt diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/LevelMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/LevelMixin.java new file mode 100644 index 000000000..9930b5a28 --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/LevelMixin.java @@ -0,0 +1,19 @@ +package ru.dbotthepony.mc.otm.mixin; + +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.Level; +import net.neoforged.fml.ModList; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import ru.dbotthepony.mc.otm.core.IMatteryLevel; +import ru.dbotthepony.mc.otm.core.util.GJRAND64RandomSource; + +@Mixin(Level.class) +public abstract class LevelMixin implements IMatteryLevel { + private final RandomSource otm_random = ModList.get().isLoaded("better_random") ? null : new GJRAND64RandomSource(); + + @Override + public @Nullable RandomSource getOtmRandom() { + return otm_random; + } +} 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 21f131c1b..a91002d1d 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAbstractHurtingProjectile.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAbstractHurtingProjectile.java @@ -8,6 +8,7 @@ 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.player.IMatteryPlayer; +import ru.dbotthepony.mc.otm.core.IMatteryLevel; import ru.dbotthepony.mc.otm.registry.game.MSoundEvents; @Mixin(AbstractHurtingProjectile.class) @@ -24,7 +25,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().getRandom().nextFloat() * 0.1f); + entity.level().playSound(entity, proj.blockPosition(), MSoundEvents.INSTANCE.getANDROID_PROJ_PARRY(), SoundSource.PLAYERS, 1.0f, 0.95f + ((IMatteryLevel) entity.level()).getOtmRandom().nextFloat() * 0.1f); } } } 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 0cc196d20..c94c15b68 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 @@ -44,7 +44,7 @@ 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.core.random +import ru.dbotthepony.mc.otm.core.otmRandom import ru.dbotthepony.mc.otm.isClient import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.registry.MDamageTypes @@ -271,7 +271,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery } // шанс 1% что черная дыра потеряет 0.1 MtU каждую секунду * силу гравитации дыры ^ -1 - if (level.random.nextDouble() < 0.01 * 0.05 * (1 / gravitationStrength)) { + if (level.otmRandom.nextDouble() < 0.01 * 0.05 * (1 / gravitationStrength)) { this.mass += HAWKING_MASS_LOSE_STEP } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/BlackHoleGeneratorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/BlackHoleGeneratorBlockEntity.kt index 5347f3248..84c9bba76 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/BlackHoleGeneratorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/BlackHoleGeneratorBlockEntity.kt @@ -34,7 +34,7 @@ import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.core.multiblock.BlockEntityTag import ru.dbotthepony.mc.otm.core.multiblock.MultiblockStatus import ru.dbotthepony.mc.otm.core.multiblock.shapedMultiblock -import ru.dbotthepony.mc.otm.core.random +import ru.dbotthepony.mc.otm.core.otmRandom import ru.dbotthepony.mc.otm.core.util.InvalidableLazy import ru.dbotthepony.mc.otm.menu.tech.BlackHoleGeneratorMenu import ru.dbotthepony.mc.otm.registry.game.MBlockEntities @@ -86,8 +86,8 @@ class BlackHoleGeneratorBlockEntity(blockPos: BlockPos, blockState: BlockState) multiblock?.blockEntities(MatterHatchBlockEntity.INPUT_TAG)?.iterator()?.map { it.matter }?.toList() ?: listOf() } - val energy = CombinedProfiledEnergyStorage(FlowDirection.NONE, energyTarget::value, { level?.random }) - val matter = CombinedProfiledMatterStorage(FlowDirection.NONE, matterTarget::value, { level?.random }) + val energy = CombinedProfiledEnergyStorage(FlowDirection.NONE, energyTarget::value, { level?.otmRandom }) + val matter = CombinedProfiledMatterStorage(FlowDirection.NONE, matterTarget::value, { level?.otmRandom }) enum class Mode(val label: Component, val tooltip: Component) { TARGET_MASS(TranslatableComponent("otm.gui.black_hole_generator.sustain.mode"), TranslatableComponent("otm.gui.black_hole_generator.sustain.desc")), 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 21ebb4928..8434ce627 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 @@ -14,7 +14,7 @@ import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.collect.reduce import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.RelativeSide -import ru.dbotthepony.mc.otm.core.random +import ru.dbotthepony.mc.otm.core.otmRandom import ru.dbotthepony.mc.otm.core.shuffle import ru.dbotthepony.mc.otm.graph.GraphNodeList import ru.dbotthepony.mc.otm.onceServer @@ -627,7 +627,7 @@ class EnergyCableGraph : GraphNodeList= failureChance * upgrades.failureMultiplier) + if (failureChance * upgrades.failureMultiplier <= 0.0 || level!!.otmRandom.nextDouble() >= failureChance * upgrades.failureMultiplier) repairProgress += progressPerTick energy.extractEnergy(energyConsumption * (progressPerTick / thisProgressPerTick), false) 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 87405bf61..d8fe21afe 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,7 +24,7 @@ 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 -import ru.dbotthepony.mc.otm.core.random +import ru.dbotthepony.mc.otm.core.otmRandom import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.item.matter.MatterDustItem import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu @@ -117,7 +117,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) stack.shrink(1) container.setChanged(0) - val actualMatter = dustMatter.matter * (0.4 + level!!.random.nextDouble() * 0.6) + val actualMatter = dustMatter.matter * (0.4 + level!!.otmRandom.nextDouble() * 0.6) return JobContainer.success( RecyclerJob( 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 944b3c954..ac9f9c181 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 @@ -28,7 +28,7 @@ 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.core.math.Decimal -import ru.dbotthepony.mc.otm.core.random +import ru.dbotthepony.mc.otm.core.otmRandom import ru.dbotthepony.mc.otm.data.codec.DecimalCodec import ru.dbotthepony.mc.otm.data.codec.minRange import ru.dbotthepony.mc.otm.graph.matter.MatterNode @@ -184,7 +184,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : task = allocation.task.id, matterValue = matter.matter, pattern = Optional.ofNullable(allocation.pattern), - asDust = (level?.random?.nextDouble() ?: 1.0) * upgrades.failureMultiplier > (allocation.pattern?.researchPercent ?: 2.0), + asDust = (level?.otmRandom?.nextDouble() ?: 1.0) * upgrades.failureMultiplier > (allocation.pattern?.researchPercent ?: 2.0), ticks = ticks, )) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AbstractPoweredFurnaceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AbstractPoweredFurnaceBlockEntity.kt index 48e11140b..4ca9c7317 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AbstractPoweredFurnaceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AbstractPoweredFurnaceBlockEntity.kt @@ -35,7 +35,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.random +import ru.dbotthepony.mc.otm.core.otmRandom import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu import ru.dbotthepony.mc.otm.recipe.MatteryCookingRecipe import ru.dbotthepony.mc.otm.recipe.MicrowaveRecipe @@ -153,7 +153,7 @@ sealed class AbstractPoweredFurnaceBlockEntity

0f) { - repairPoints += if ((level?.random?.nextFloat() ?: 1f) <= diff) 1 else 0 + repairPoints += if ((level?.otmRandom?.nextFloat() ?: 1f) <= diff) 1 else 0 } experienceStored -= 1 @@ -202,7 +202,7 @@ class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma level!!.playSound(null, ent.x, ent.y, ent.z, SoundEvents.EXPERIENCE_ORB_PICKUP, SoundSource.BLOCKS, - 0.1F, 0.5F + level!!.random.nextFloat() * 0.25F + 0.1F, 0.5F + level!!.otmRandom.nextFloat() * 0.25F ) } 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 1db3ae35b..bc8c6e1aa 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.container.HandlerFilter 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.random +import ru.dbotthepony.mc.otm.core.otmRandom import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu import ru.dbotthepony.mc.otm.registry.game.MBlockEntities import ru.dbotthepony.mc.otm.registry.game.MRecipes @@ -90,7 +90,7 @@ class PlatePressBlockEntity( recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess), recipe.workTime * MachinesConfig.PLATE_PRESS.workTimeMultiplier, MachinesConfig.PLATE_PRESS.energyConsumption * toProcess, - experience = recipe.experience.sample(level.random) * toProcess)) + experience = recipe.experience.sample(level.otmRandom) * toProcess)) } override fun tick() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/IMatteryLevel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/IMatteryLevel.kt new file mode 100644 index 000000000..583febb3c --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/IMatteryLevel.kt @@ -0,0 +1,17 @@ +package ru.dbotthepony.mc.otm.core + +import net.minecraft.util.RandomSource +import net.minecraft.world.level.Level +import net.neoforged.fml.ModList + +interface IMatteryLevel { + /** + * OTM provided [RandomSource], which has better statistical parameters + * + * Original Minecraft use LCG, which may show bad behavior when repeatedly sampled *a lot*, + * which is what [Level]'s random is used for. OTM provided PRNG should behave better in this scenario. + */ + val otmRandom: RandomSource? +} + +val Level.otmRandom: RandomSource get() = (this as IMatteryLevel).otmRandom ?: random 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 5c66894fb..ee09e29ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt @@ -19,7 +19,7 @@ import net.minecraft.world.level.block.state.BlockState 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.random +import ru.dbotthepony.mc.otm.core.otmRandom import ru.dbotthepony.mc.otm.core.position import ru.dbotthepony.mc.otm.menu.decorative.MinecartCargoCrateMenu import ru.dbotthepony.mc.otm.registry.game.MItems @@ -90,7 +90,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().otmRandom.nextFloat() * 0.2f) this.gameEvent(GameEvent.CONTAINER_OPEN, player) PiglinAi.angerNearbyPiglins(player, true) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt index 386c0bb06..d7d1bb5d4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt @@ -7,7 +7,7 @@ import net.minecraft.world.item.Items import net.neoforged.bus.api.SubscribeEvent import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent import ru.dbotthepony.mc.otm.config.ServerConfig -import ru.dbotthepony.mc.otm.core.random +import ru.dbotthepony.mc.otm.core.otmRandom import ru.dbotthepony.mc.otm.registry.game.MItems @@ -17,8 +17,8 @@ object WitheredSkeletonSpawnHandler { val entity = event.entity if (entity is WitherSkeleton) { - val giveHelmet = event.level.random.nextFloat() < ServerConfig.WITHER_SKELETON_HELMET_CHANCE - val giveSword = event.level.random.nextFloat() < ServerConfig.WITHER_SKELETON_SWORD_CHANCE + val giveHelmet = event.level.otmRandom.nextFloat() < ServerConfig.WITHER_SKELETON_HELMET_CHANCE + val giveSword = event.level.otmRandom.nextFloat() < ServerConfig.WITHER_SKELETON_SWORD_CHANCE if (giveHelmet) { if (!entity.hasItemInSlot(EquipmentSlot.HEAD)) 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 a4f9651b0..281cdc63f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt @@ -185,7 +185,7 @@ class CrudeBatteryItem : BatteryItem(ItemsConfig.Batteries.CRUDE) { if (player is ServerPlayer) { if (!mattery.androidEnergy.item.isEmpty) { mattery.androidEnergy.item.getCapability(Capabilities.EnergyStorage.ITEM)?.let { - it.extractEnergy((it.maxEnergyStored * level.random.nextFloat() * .2f).roundToInt(), false) + it.extractEnergy((it.maxEnergyStored * level.otmRandom.nextFloat() * .2f).roundToInt(), false) } mattery.dropBattery() @@ -195,7 +195,7 @@ class CrudeBatteryItem : BatteryItem(ItemsConfig.Batteries.CRUDE) { copyStack.count = 1 mattery.androidEnergy.item = copyStack - val extraDamageMult = level.random.nextFloat() + val extraDamageMult = level.otmRandom.nextFloat() player.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EMP), inflictor = itemStack), 1.5f + extraDamageMult * 3.5f) val debuffDuration = 100 + (100 * (1f - extraDamageMult)).roundToInt() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/EssenceCapsuleItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/EssenceCapsuleItem.kt index df8008a1c..9d7ddbbdd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/EssenceCapsuleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/EssenceCapsuleItem.kt @@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.player.matteryPlayer 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.otmRandom import ru.dbotthepony.mc.otm.core.util.getLevelFromXp import ru.dbotthepony.mc.otm.item.MatteryItem import ru.dbotthepony.mc.otm.registry.game.MDataComponentTypes @@ -80,7 +81,7 @@ class EssenceCapsuleItem(private val digital: Boolean) : MatteryItem(Properties( } else { if (level is ServerLevel) { level.levelEvent(2002, player.blockPosition(), PotionContents.getColor(Potions.WATER)) - ExperienceOrb.award(level, player.position(), (exp * (.5 + level.random.nextFloat() * .25)).toInt()) + ExperienceOrb.award(level, player.position(), (exp * (.5 + level.otmRandom.nextFloat() * .25)).toInt()) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/ImperfectBreadItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/ImperfectBreadItem.kt index 9a3022448..089de13fc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/ImperfectBreadItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/ImperfectBreadItem.kt @@ -9,7 +9,7 @@ import net.minecraft.world.entity.item.ItemEntity import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.random +import ru.dbotthepony.mc.otm.core.otmRandom import ru.dbotthepony.mc.otm.core.position import ru.dbotthepony.mc.otm.entity.BreadMonster import ru.dbotthepony.mc.otm.item.MatteryItem @@ -39,7 +39,7 @@ class ImperfectBreadItem(properties: Properties) : MatteryItem(properties) { // roll multiple times so multiple bread monsters can spawn on tick // and also chance be less biased for (i in 0 until stack.count.coerceAtMost(16)) { - if (entity.level().random.nextFloat() < 0.001f) { + if (entity.level().otmRandom.nextFloat() < 0.001f) { val ent = BreadMonster(entity.level()) ent.position = entity.position entity.level().addFreshEntity(ent) 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 a79ab1ead..018d1d474 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 @@ -84,7 +84,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) itemStack.hurtAndBreak(8, level, player) {} if (isPrimed(itemStack)) { - itemStack.hurtAndBreak(level.random.nextInt(1, 20), level, player) {} + itemStack.hurtAndBreak(level.otmRandom.nextInt(1, 20), level, player) {} unprime(itemStack) val (ex, ey, ez) = Vector.atCenterOf(player.blockPosition()) @@ -226,7 +226,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) val copy = itemStack.copy() - itemStack.hurtAndBreak(level.random.nextInt(1, 20), attacker, EquipmentSlot.MAINHAND) + itemStack.hurtAndBreak(level.otmRandom.nextInt(1, 20), attacker, EquipmentSlot.MAINHAND) if (!itemStack.isEmpty && attacker.random.nextDouble() <= ToolsConfig.ExplosiveHammer.FLY_OFF_CHANCE) { attacker.setItemInHand(hand, ItemStack.EMPTY) 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 bd42bfb5f..666ffbac2 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 @@ -32,6 +32,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.math.nextVariance +import ru.dbotthepony.mc.otm.core.otmRandom import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.item.MatteryItem import ru.dbotthepony.mc.otm.item.addSimpleDescription @@ -96,10 +97,10 @@ class EnergySwordItem : MatteryItem(Properties().stacksTo(1).rarity(Rarity.RARE) itemStack.getCapability(MatteryCapability.ITEM_ENERGY)?.let { if (it.extractEnergyExact(ENERGY_PER_SWING, false)) { - it.extractEnergy(attacker.level().random.nextVariance(ENERGY_PER_SWING_VARIANCE), false) + it.extractEnergy(attacker.level().otmRandom.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) + it.androidEnergy.extractEnergy(attacker.level().otmRandom.nextVariance(ENERGY_ZAP_VARIANCE), false) victim.hurt(MatteryDamageSource(attacker.level().registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f) } } @@ -142,12 +143,12 @@ class EnergySwordItem : MatteryItem(Properties().stacksTo(1).rarity(Rarity.RARE) 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().otmRandom.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().otmRandom.nextVariance(COBWEB_POWER_COST_VARIANCE), false) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/FallingSunItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/FallingSunItem.kt index c5ce968ff..d4f636c9e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/FallingSunItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/FallingSunItem.kt @@ -32,6 +32,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.math.nextVariance +import ru.dbotthepony.mc.otm.core.otmRandom import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.item.MatteryItem import ru.dbotthepony.mc.otm.item.addSimpleDescription @@ -96,10 +97,10 @@ class FallingSunItem : MatteryItem(Properties().stacksTo(1).rarity(Rarity.EPIC)) itemStack.getCapability(MatteryCapability.ITEM_ENERGY)?.let { if (it.extractEnergyExact(ENERGY_PER_SWING, false)) { - it.extractEnergy(attacker.level().random.nextVariance(ENERGY_PER_SWING_VARIANCE), false) + it.extractEnergy(attacker.level().otmRandom.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) + it.androidEnergy.extractEnergy(attacker.level().otmRandom.nextVariance(ENERGY_ZAP_VARIANCE), false) victim.hurt(MatteryDamageSource(attacker.level().registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f) } } @@ -142,12 +143,12 @@ class FallingSunItem : MatteryItem(Properties().stacksTo(1).rarity(Rarity.EPIC)) 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().otmRandom.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().otmRandom.nextVariance(COBWEB_POWER_COST_VARIANCE), false) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt index fbc7c2cb9..72b92aaf2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt @@ -24,6 +24,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 import ru.dbotthepony.mc.otm.core.math.toRadians +import ru.dbotthepony.mc.otm.core.otmRandom import ru.dbotthepony.mc.otm.core.position import ru.dbotthepony.mc.otm.core.readItem import ru.dbotthepony.mc.otm.core.writeItem @@ -445,7 +446,7 @@ class ExopackSmokePacket(val player: UUID) : CustomPacketPayload { z += kotlin.math.sin(deg) * -0.4 val level = ply.level() - val random = level.random + val random = level.otmRandom for (i in 0 .. random.nextInt(2, 4)) level.addParticle( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/SmokeParticlesPacket.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/SmokeParticlesPacket.kt index 5ab9cc173..5d87e004a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/SmokeParticlesPacket.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/SmokeParticlesPacket.kt @@ -13,7 +13,7 @@ import net.neoforged.neoforge.network.handling.IPayloadContext import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.ResourceLocation -import ru.dbotthepony.mc.otm.core.random +import ru.dbotthepony.mc.otm.core.otmRandom class SmokeParticlesPacket(val x: Double, val y: Double, val z: Double) : CustomPacketPayload { fun write(buff: FriendlyByteBuf) { @@ -24,7 +24,7 @@ class SmokeParticlesPacket(val x: Double, val y: Double, val z: Double) : Custom fun play(context: IPayloadContext) { minecraft.player?.level()?.let { - makeSmoke(x, y, z, it.random, it) + makeSmoke(x, y, z, it.otmRandom, it) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt index a8a906d5f..99e72ad24 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt @@ -528,7 +528,7 @@ class MatteryPlayer(val ply: Player) { override fun onJobTick(status: JobStatus) { super.onJobTick(status) - if (isExopackVisible && ply.level().random.nextFloat() <= 0.05f) { + if (isExopackVisible && ply.level().otmRandom.nextFloat() <= 0.05f) { PacketDistributor.sendToPlayersTrackingEntityAndSelf(ply, ExopackSmokePacket(ply.uuid)) } } @@ -1319,7 +1319,7 @@ class MatteryPlayer(val ply: Player) { 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().otmRandom, ply.level()) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/EnderTeleporterFeature.kt index 807d461b1..2f0bd1cbf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/EnderTeleporterFeature.kt @@ -49,6 +49,7 @@ 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.core.otmRandom import ru.dbotthepony.mc.otm.milliTime import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures import ru.dbotthepony.mc.otm.triggers.EnderTeleporterFallDeathTrigger @@ -302,7 +303,7 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A val event = EventHooks.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().otmRandom.nextLong())) return false } @@ -310,9 +311,9 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A lastTeleport = ply.server!!.tickCount android.androidEnergy.extractEnergy(PlayerConfig.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().otmRandom.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().otmRandom.nextFloat() * 0.4f) ply.deltaMovement = Vector(0.0, 0.0, 0.0) ply.resetFallDistance() diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index 5a114f337..9fafe0491 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -17,7 +17,8 @@ "HopperBlockEntityMixin", "DispenserBlockEntityMixin", "GuiGraphicsMixin", - "BlockStateBaseMixin" + "BlockStateBaseMixin", + "LevelMixin" ], "client": [ "MixinGameRenderer", From 42386e1fbe095ccaaaedc19021f4889488991f23 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 15 Mar 2025 10:08:02 +0700 Subject: [PATCH 18/46] Update commentary on `otmRandom` --- .../dbotthepony/mc/otm/core/IMatteryLevel.kt | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/IMatteryLevel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/IMatteryLevel.kt index 583febb3c..383f1c521 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/IMatteryLevel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/IMatteryLevel.kt @@ -5,13 +5,25 @@ import net.minecraft.world.level.Level import net.neoforged.fml.ModList interface IMatteryLevel { - /** - * OTM provided [RandomSource], which has better statistical parameters - * - * Original Minecraft use LCG, which may show bad behavior when repeatedly sampled *a lot*, - * which is what [Level]'s random is used for. OTM provided PRNG should behave better in this scenario. - */ val otmRandom: RandomSource? } +/** + * OTM provided [RandomSource], which has better statistical parameters + * + * Original Minecraft use LCG, which may show bad behavior when repeatedly sampled *a lot*, + * which is what [Level]'s random is used for. OTM provided PRNG should behave better in this scenario. + * + * The way OTM uses random generator in its code will quickly cause LCG used in Minecraft to show its bias + * because LCG in minecraft samples its highest 48 bits, which gives us at best 2^16 period in the lowest bit returned by LCG. + * Which it doesn't sound bad, it quickly causes RNG become biased the quicker/more it is sampled on each tick, especially considering + * some may use `level.random.nextInt(chance) == 0` to determine chance of something happening, + * which will get extremely biased on heavy RNG congested environment + * If we avoid sampling Level's generator this much, we won't suffer from bias in our own code, as well as avoid biasing other mods this much. + * + * The "2^16 period" problem is also might be the reason why Entities get their own instance of RandomSource, + * and Mob Goals use random exactly the way described above (`nextInt(chance)`), which can and will suffer + * from bias the moment mob exists in world for more than 2^16 ticks (but actual bias will happen sooner + * because RNG is not sampled only once per tick, obviously) + */ val Level.otmRandom: RandomSource get() = (this as IMatteryLevel).otmRandom ?: random From 962ecb1996f132060c491b4bc6b4205608785bf8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 15 Mar 2025 10:42:45 +0700 Subject: [PATCH 19/46] Use nextDouble() because PRNG provides 64 bit numbers --- .../kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt index d7d1bb5d4..c40ff4f28 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt @@ -17,8 +17,8 @@ object WitheredSkeletonSpawnHandler { val entity = event.entity if (entity is WitherSkeleton) { - val giveHelmet = event.level.otmRandom.nextFloat() < ServerConfig.WITHER_SKELETON_HELMET_CHANCE - val giveSword = event.level.otmRandom.nextFloat() < ServerConfig.WITHER_SKELETON_SWORD_CHANCE + val giveHelmet = event.level.otmRandom.nextDouble() < ServerConfig.WITHER_SKELETON_HELMET_CHANCE + val giveSword = event.level.otmRandom.nextDouble() < ServerConfig.WITHER_SKELETON_SWORD_CHANCE if (giveHelmet) { if (!entity.hasItemInSlot(EquipmentSlot.HEAD)) From f599f1c2b983b1426e8c23dcb93505867fda448a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 15 Mar 2025 13:23:34 +0700 Subject: [PATCH 20/46] Fix saturation going negative --- src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt index 62b9a8e82..9f442d2df 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt @@ -79,7 +79,7 @@ class MatteryFoodData(private var player: Player) : FoodData() { if (saturationLevel > 0f) { val satisfied = min(saturationLevel.roundToInt(), points) points -= satisfied - saturationLevel -= satisfied + saturationLevel = max(0f, saturationLevel - satisfied) } foodLevel = max(0, foodLevel - points) From df5c8dc6aa95d14185f0d893f8eaea52201a6dd6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 16 Mar 2025 00:31:05 +0700 Subject: [PATCH 21/46] Make Matter Decomposer throttle for 1 tick when buffer can't fit all matter produced --- .../entity/matter/MatterDecomposerBlockEntity.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 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 8ed8a703e..c4d753c96 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 @@ -106,10 +106,15 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) if (!status.job.matterValue.isZero) status.throttleFast() } else { - status.job.matterValue -= matter.receiveMatter(status.job.matterValue, false) + val received = matter.receiveMatter(status.job.matterValue, false) + status.job.matterValue -= received - if (status.job.matterValue.isPositive) - status.noMatter() + if (status.job.matterValue.isPositive) { + if (received.isPositive) + status.noMatter(1) + else + status.noMatter() + } } } From 9a5614de6549a91b6d2e1b68a1df17eb9a05c019 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 16 Mar 2025 17:29:13 +0700 Subject: [PATCH 22/46] Don't drop experience capsules when keepInventory is enabled --- .../java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java | 3 ++- 1 file changed, 2 insertions(+), 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 5ddfd3c17..23a6aafc4 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.mixin; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.GameRules; import net.neoforged.neoforge.event.EventHooks; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; @@ -28,7 +29,7 @@ public class MixinLivingEntity { at = @At("HEAD"), cancellable = true) public void dropExperience(@Nullable Entity killer, CallbackInfo hook) { - if (((Object) this) instanceof Player player && ServerConfig.INSTANCE.getDROP_EXPERIENCE_CAPSULES()) { + if (((Object) this) instanceof Player player && ServerConfig.INSTANCE.getDROP_EXPERIENCE_CAPSULES() && !player.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY)) { hook.cancel(); var android = ((IMatteryPlayer) player).getOtmPlayer(); From 5b68a6c7ba4857cb1e0eba73d6b8d4aceaae5df5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 17 Mar 2025 11:23:34 +0700 Subject: [PATCH 23/46] Add "quick move" to/from storage graphics --- .../mc/otm/client/render/WidgetLocation.kt | 2 +- .../mc/otm/client/render/Widgets18.kt | 8 +++++++- .../textures/gui/widgets/storage_controls.png | Bin 1071 -> 1371 bytes .../textures/gui/widgets/storage_controls.xcf | Bin 11478 -> 15956 bytes 4 files changed, 8 insertions(+), 2 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 76ca2623a..bbd38299b 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.client.render.sprites.MatteryAtlas import ru.dbotthepony.mc.otm.core.ResourceLocation object WidgetLocation { - val STORAGE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/storage_controls.png"), 90f, 72f) + val STORAGE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/storage_controls.png"), 90f, 90f) val WIDGET_18 = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/widget_18.png"), 72f, 72f) val WIDGET_15 = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/widget_15.png"), 60f, 60f) val WIDGET_8 = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/widget_8.png"), 64f, 32f) 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 06bab6193..21aa5a69c 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 @@ -6,7 +6,7 @@ import ru.dbotthepony.mc.otm.core.immutableMap import ru.dbotthepony.mc.otm.core.math.RelativeSide object Widgets18 { - private val storageGrid = WidgetLocation.STORAGE_CONTROLS.grid(rows = 4, columns = 5) + private val storageGrid = WidgetLocation.STORAGE_CONTROLS.grid(rows = 5, columns = 5) val SORT_DESCENDING = storageGrid.next() val SORT_ASCENDING = storageGrid.next() @@ -24,6 +24,12 @@ object Widgets18 { val PLAY = storageGrid.next() val STOP = storageGrid.next() val SORT_NOW = storageGrid.next() + val MOVE_EVERYTHING_TO_STORAGE = storageGrid.next() + val MOVE_EVERYTHING_FROM_STORAGE = storageGrid.next() + val RESTOCK_TO_STORAGE = storageGrid.next() + val RESTOCK_FROM_STORAGE = storageGrid.next() + val RESTOCK_WITH_MOVE_TO_STORAGE = storageGrid.next() + val RESTOCK_WITH_MOVE_FROM_STORAGE = storageGrid.next() private val miscGrid = WidgetLocation.WIDGET_18.grid(4, 4) 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 0c33af3f2bb17a5f806efa7c82d70f66f9efde76..054f10becee5be6977e92b4c905e07d6cb286bcb 100644 GIT binary patch delta 1312 zcmV+*1>gFw2-^yf7YbSk1^@s6IH*Aaks%x&P!xqvQ>7x6B6bjU$WWc^q9Tr^ibb$c z+6t{Yn7ol&Ab#<}FMz%#=}Ha$-qCKgLwEO#+08!GV(aYRuy%6}JfE-Re3IIGn zxk5(IQ7cXdAe=?r8EJaJd5v zKk1SoIe(I$N+=eA_cQvYJTP<%^sl*dYoFuv0m#yTS z5r3&%o*JJMG5hgUdz5h;Tiok&Bj&sHV)juj4u%I}h%{X!DSo1cAXsyBr z1q%QG00000&_GL5O?D4@Se58d%^$lJL0UaV9CewbF4^lsS^*MAHE005x!8dJLTPCa*tx;VXFub_&#Uaz)y zsv{i7QqRJWJ}cwz@1N$^j}K#vF`wUm%;o;hmYz9hp*j9IiIb^H?`TZw^CMjDZ}VmT zU(7{O-%H8n_~WF`#vDt{fSgmM8WF8|s#H?^styrrQaXO+~b!j3_NA%Gy9+zxHG_%7Jde8|Xng&*fMf%_QdU*#~ zRxwAH>_oKaqIXMlsYOh>s3M}d`AYa7eGt*a>QbYmKZU%LMla<($TB5ahE4;4=AO2K4+Pb7{q-LQx^i03vfo%23%h?OOU_?&pkpbHW| za$R=$jdRIifoFz{Y&uRHA{I+sEO#+08!GWEaad6`%6}JfE-Re3IIGniARSlF3y8BgX=2P$4;f@IUz7TeCPb z?Is0dK<|rfe@p;@U7*#l?eAmTZk+)BXW&Zf_-jpI{*&}ZM++YTL)*Z`bw`u;fXf|V zwQCxAr+sAAl_NYWW5@I0Pn3l)dip?!NB6{ae%S z-w$G{}w{XfO3AvD5g{&M&U0 zcYph2j!`Lz=vuT}R++?JB^}Z%qxbSV`qvV4wpzN6S+jJcgOM&lsiv0nRYOwA&O)+< zr?{F-Xr#hIoW!R^I>ZGF#ffainWbabZ4J?0g%1S_000000JtERmZY@N{ldVf#ir!}Z*h*Gk=$(OVz^ET!gS(-j{&5x!* zbW4pcHTktfX#BLE)UX*kr*)bS&~-Ds6Nx4HJKB_1LmV;Sv*Ud)4Ln{s@bDu&Wx3?4 z!c!|i>F*H=eK%`!dIxm+O$iPF004OBk5~Cw6`M4b@gk|Ux83^TuKM7chLEeto_`@9 zb|w0(<}dvf!CFbJOt$65|E4J|JsUx*S9&fH{rCDQWczQ1chKTl#=6~QX)c}KdC9{H zWcQY`ZS@JPGRDoC$ZJj<{!QfSig8pR47=AcV`N*$WU-5PuKs5F@XH)!S^q7&;+_Ej z002A-UMCvBSb{_LAfh3AAkmOLfIDa^tAP;>*^NYN@a9nP}u-U_?Xq gKn+a 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 894ea7b4b51d74b4b16bcdc5200851e7e5f64c4b..3dbdd5d0e433eb90145f6929a9148a7ce041b823 100644 GIT binary patch literal 15956 zcmeHOTWnlM8J@j+cfEElrgog9-B1VHN!{2Xc8wAf2^Ep{0aXGCRFG3QOOBgJ0x z*Vhg8(-G>vqWPox`SHUed&Ulq7W;a^y)c7wOwX4OjvXzI9o+Nm-f@;Vv~S<|-lIj6 z-=i%#Gc%vr3-QgCNfm9{khW>=vP}zb*>uH^Y`XfZHf?>#rfbgGblp#FTI{mvgHHdE z^_K7Yn@umf6A+#%hG(ID1xYcSfbeX1F1%Pe5uPa>E1lw92?z!nfFRI_ z8%XawhAV)ANI5IZIvR=kut%@+=$uCvJv#5vjUHX_=w{HYk1w|iF@wmudH;=$Mxr`M zYXqbZdb9xfdysh{@vO&)@pxZ^#7j0cSJ6@aW07~O)Kp$gPhEQV-Af?mFcj#i1R|AL z71PM8^`)tVPJxL{#k8JE8oI1VsAe5k1;hlDj7i<0q^AC%q5g7B9urklzt;VcH95t? zHC@*Fa=9jtiK@w{qu$9W=B-J?E)h{{*i1h_6CrIxs#P5MET2P}Mp&l_yy>gbHpJo1 zTLt|@cz!PIUuMhJ6WsYcwZNTz+Y9N>d5oCN!96`5p@S%WQskXzgsW%}cmkbPd7T7I zQ=TjX`UC3Ynxtf1JGW!Z=rXCP%nYp8SdG^!rl&mSHdk|b-u^N3Z8ig?O?baXptj%; zJR8yLB6|UQhV2R6YyoL5qI@74<&&Okp9^l|)9VS`1oi-8wZ7c+R+M)kyG=O|>h_Yq>FCMlAUmkPb_RjnAN=C2m4EG*=|2cwbg zOzZBnLiJSZ zy9L1yEY@Flhp$D zONiU#qSwMb^Ol)eX$oMEAto`2Ng$@3zLRYtZOBQ<<|vRa4R6iYs0HT7X^To&Ia#60 zCUP)e`KJgSL@WO(@?~#rml(2cxK(f6>42GbKutQ}64X(^#{CzZv&@-ww}!8Wlh_{ z`s0TFAW#8Vseq~is!j#%YWYEF)!S*&?dW$gM7wVj*Ez!{GzYO5Ht8Ci{<_j-n)^K| z^&hjvz-@igCAJf~3IRPODq-^*)`s!q8z*tW`ls$|yt7;d% zgDC5TwjPfW1GpaA_E>}tqP7u{ccVL?X#$O&no&9Q&{&WG78aXgCkW-@rnm84*G*R| zm@c*v8<=-bEyF4U5Y8WmX{`I>Z!h9j>)+%Hx*#TS;9g&z|3EJ~kn79qUu+8-uX_dHHj^2m z*kdX)CW2aKPxEB52)CK$qv_D&!Fy7jan7^(ne(EJYWX3>^uATAvEnK4JT z9T;>15huGr+|UK^1#S8nyy?AGab=u|X^yirtep2Ys%yr+lu=i}nA3zYhieDgP@?6< zj%Y}6wj7Jv!Z-N6L+Mm_fgeEBZ6_f9YUu=Ryg?;&?5NOXd$>-}@%acHL>-4kZaaZJ zujGoY(g7UcT?YWBp(VCCK-ptokQ_n?e>%>^!GF0*f?bXnBwZBX@0$&HGXk(>>&fSH z^~-Kr?drFcFH{Mgn=ABexOaXkLI+XjZjlr2VrxJ3JUrJGaQDW;n?(k8m$0ayi{}p0 zt-E;t{zBhv^)#w0;wK1Q=RM?;9d74{>t=cr_k9{}yL231tWAb*VZl7fkJ-WrHeEg8 znTy_9@Vr{EXw&X%9xub0bKjeM?28WBH*JwJU%+6AWvy}2bjsM>jA0XX8oQ+UelM>7 zZuUb}pHpQ+IuBZd$@A2#*kGNSKj^yvENV z0cMz6T_uVCbOiUl)0H#BgbHP1`XJj(8jWHdmFBd>%>}Nl;`)Gv`f^>f(Yz=d zqS2%siT4JB_s1S(Th^09muIXNHP z<$J=eVrQbXNk(vNyp>+0(d)^t@p<^P)gqDQys+(O9wSz8NZj_j2pvS*{wVSh%z(HE z`lL%i2P3K$sri0go`bE?Zd(JJKUhLcl)i~M6&Da^>#t?FBxb0#Wr#8_41C;U#3HU` z2A+)2K{RkgNgfBd`I|_d zqDjPlMAQn4s0qx`@ms0-o1KgQuNFrRBYbU!!Ee~qT*VG9&)^#oI+nR0@?muYYekjB z4haCo1rk5>Nm;4=VFMOSIKs6f4>NOpsqoQ_Jhj!qLCj~C#yxjqFm2{w zYTh~njxWj8Vg@Iuq#KOPyl>W!eBGR(%-bHK8O7$r-oxRmaAfB(3p!)m*qPFIO5a*C zvmm|+L$%1{?+d-Kz34GwC5O!IQTyM>zWuXOW)PpJ-^=n0P(`#8J|?T^qwH1v|l2fg-BIb0Zoz$XDOK#_b5WO2o#eSVoT1gun$ W^S>(jxWhtg85{QL);jF$RR0Clymbly delta 676 zcmcaob1ia$sFVi-1WW@`fDtX@(#lLsJgRWrJdR-9JdvBv%f>M?@$ZDo z@LvUM=YI>cJVvQ*^9w~UCMKbMFhz_)lP?O2GYNg#oT0LliAi)VOoB=DBuF=t=)=w7 z>a&=bBx>O@5;K8JamJ0C)wQ-WF-d2^C8XOxS~#WW!7Pl|%blE{mjl9^6ZDc8ndJQ7 ziseB1#F*roHviCMiqGdR&QbTgkN2NRR#BDf+=P}qnuX Date: Mon, 17 Mar 2025 22:28:02 +0700 Subject: [PATCH 24/46] Rearrange icons in quickmove --- .../textures/gui/widgets/storage_controls.png | Bin 1371 -> 1303 bytes .../textures/gui/widgets/storage_controls.xcf | Bin 15956 -> 16168 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 054f10becee5be6977e92b4c905e07d6cb286bcb..d46201f5e4b8bb78105dec2c9e8c3a39eb5432a1 100644 GIT binary patch delta 847 zcmV-V1F-zt3YQA7x&aCQ0RI60puMM)lfwZae-9fayY%uP0009NNkl(>{z+s$g23{CA_WQ7od zf3?=G2Nb)`5wo;e%iVqE1tM~`JlDQNW47(7@+j>%vbf{(Big%VFk7vpXmn27C9{mu zo@F|yUPkTdx0TN&C^lQF_n9+wsGXrsL8?tn*;fupsdf^QB|Q1j%ml|&NQk4zl$Z{3 zz=Gg}Hsi#mW3k&DqO}4a1S|jm00000e?S9Yn&QsFy@MY;8PO#bj*<$AH1AwXPS+Z} zgx2eP0EhTgvOh&!>VFhDrAn29r;?>jJ|#W5PGiQ%;^d)oaySX1L)z$6lAlWiM^0&_ z28*GxTgQ0;RTsk}k(e@n+cv4$;P>coth}#f1GifaG~`gLEKRm5%o+hwfA^qJe|NDK zyLSN3ej@}200000ZU3>AoKfMZu8bB*rMd0W7uV{AI}RbO$?m})RwX(X^QVp?NF%9{ z$(HQ+cbw2tGZ8d;q^F|M54WF!Z2iUX2)4MFzPh7K&7s{pE%Pt}*|klX8+`zy^wCKj zc}~UQ(Lh>9jC(1fV)NE;=ehnEa_?45!Va=007`1$oa=q|5-~; zE&sjv3`HW)moBvLnCY9s2=Aee{g+@m-x(3=pi{(F=hTWlqZ|ML0AK*rszl6|E7|=F%UaeCl++tt%lz60Py!D1`SwIU5_@TSa4ZJlwY1TmJX3ME92eg+@c8q0vLScR&T85&-}} Z8h?d1Z`G{4zsmps002ovPDHLkV1gfOq=*0j delta 915 zcmV;E18n@43fl^>x&a9Q00000`9r&ZlfwZae*_UG)JLT8000A6Nkli%y&tj@``fc%>Df8Ifu_w8wo-Q8_Qmu0v>GWxGkRBB zf8KjTS5vg3B8lMv}`|(tJlyMwe-0O2A=DYP`_EAZR=v1^z zW*KEXD|Jv+M(OFdx6dUgG+T=M%$Yh=XQ)$l|xc&oP=ZvPj0j{!ATVo;wUyH zse@dwpg5t;IC1J&^EQWQt-=Qd3jhEBe*gdg&_GL5h z9nouPz1`=QbO^zy@wF0ERfA2t{ z?qV&LcK|PcqXY*40001O{n*ORs92~{MvJ7}z3to|uGJ5|a0qElb`N@3mFQ5-AG;Mn zT1kyew&cYB!YM5^H-bj5^i(4H@c1dn)?W-~$i=<*y38^)hn9C*>0t!2OQ*7B^a~ip z$3-gSIUR?i3u#?3)(V7b=Q?_fe{88wl5uY4>aV9CewbF4^lsS^*9-sv0HE?3Q@Zp{ zJ$H$^IK5u4po+O(ueOAL+Wt7IBOJ$4&%%&CE939)pXS$(4`YlmpWlDX<^Il=o;hcs zIsQ0_lc`GYXiVz!BV6up^JV^D%tcY(OUdT=mpVpqP1?kDH%bd`r|^XqKAl%-NPL#d^jnjMB$VAe)a*HYMU^LlTsy5Qfc_t zy$njpOz!8UW#ZY7BLe^cearyzCVs6>#H?^styrrQaXO+~bs|nj^wBOJmuy5dv%?a4 z&XR=s`HWbbAQ$$$SigOo|9Crn#IQ%PuOo?BPGmf4=!<=J(CK>ABr| zgP%$wZ~MWP6=AOQ#IDTRGM&86VBoowlTvtV?H!x4>L9l%!{V`4CY77b}?rA zRWIpt=NuXy9UbPK2Exp6bkcS@U5FdD!2khQH&+oYJ~t~urN7KQWm}9{bIE5V64oF2 zoX+{=8)Iy2_I!oa)0+|zJoEpPl#>^p#aZ_} zCWvvGD$1}qPp0wwlUZ_hXktAA*@CQRCex%`<-DMZ^+-SqaX#A|)W09l-1zgQXE|TS zZ&fhv%fom`S3%&dtb)KeZ3y%MWS!AY)^%9}S%aw>h@uQxbsU_{|EUrb%Gr+^T;0sY z@05!V^ho03j?R_#-(e@k6`js(*|xZLs`#DEiPB=$boopY5;8l$vcwfQ^+8j$nfYU+FA4%Fw;hfDUFgE+EUyPQ1(hY zWgnzd?xMwIj{qv4Xs2>SINr)nsf=w^M@W0sVe!%Ss(l!$Z|K3*A}$QoZ|JvJKH!hq zsPV~JY9gswZm#)3x72LMV4c*1tZOpbx<_Bv9>7o^)J}bsbm}+LgLOf`ak8T>SH7q5 uZee)ims9h0#COrmxEJsj9o!&JCJYTFbnE&_42?zFX>68G<8IQE82JgvESy3B delta 1412 zcmds!O=uHA6vy|yeAqN!jg3vSX-v{an>L9FZIZS&$w`nZXv9JV5fu*#77@LcdQd9Z zOLaU|5b=Z7iWZy%tvJX|PIdtVne}m)dksYV(*>UqY&XPHNi&so|K^4x_#|D9^DkQsW<` z?pu%_wX)?QL^}y)g$9zkWhRh>AXK zyQWA(2tv$f>3}#tX-NT$urnqVtykH*WD8m+dD%LPkRfO*)uG*XK}MqJHxSmXZtz6og|BQhAiGP zpWHQS!qz0w)*+&;XL-_p4pG&Js-KCfHLe9_5QC412FrD73oaW0^P{1|z)GPfd^&s{ zFw#e^$Z>K-E*dVD?il9_?S~Mfc``&#(D3MGp5HT%5GUAqkYML&9*<2UcC8WZ_7Uw) z@wM(3h>0rEq*@L z7rxFG*h032uV)(pbH%y|a_rcE*P=UeS9q~+Cu08uHTOTH=KlGO=1&7pd2at4K$z-- Zd3xpGFc0TzfQ1s#!YI+g4OS|yd Date: Tue, 18 Mar 2025 18:27:29 +0700 Subject: [PATCH 25/46] Ignore /.kotlin --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7f6f1c7a6..4aaaaa2b5 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ forge*changelog.txt shapegen_output.java /runs +/.kotlin From 2f016a76a6d85f6b2b4a3a14e0949492c62eb094 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Mar 2025 18:27:54 +0700 Subject: [PATCH 26/46] Declare registerNetworkPackets as internal --- src/main/kotlin/ru/dbotthepony/mc/otm/network/NetworkPackets.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/NetworkPackets.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/NetworkPackets.kt index 1dcb38afa..b97728212 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/NetworkPackets.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/NetworkPackets.kt @@ -19,7 +19,7 @@ import ru.dbotthepony.mc.otm.menu.matter.PatternsChangePacket import ru.dbotthepony.mc.otm.menu.matter.ReplicationRequestPacket import ru.dbotthepony.mc.otm.menu.matter.TasksChangePacket -fun registerNetworkPackets(event: RegisterPayloadHandlersEvent) { +internal fun registerNetworkPackets(event: RegisterPayloadHandlersEvent) { val r = event.registrar("1.5.0") // world From 442a7b74962f4ddeeb7802195bde666163555072 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Mar 2025 18:40:07 +0700 Subject: [PATCH 27/46] Declare event listener functions as internal --- .../dbotthepony/mc/otm/GlobalEventHandler.kt | 16 +++++++-------- .../mc/otm/OverdriveThatMatters.kt | 1 - .../mc/otm/block/entity/MatteryBlockEntity.kt | 12 +++++------ .../entity/decorative/DevChestBlockEntity.kt | 2 +- .../mc/otm/capability/drive/DrivePool.kt | 2 +- .../mc/otm/client/AndroidAbilityKeyMapping.kt | 6 +++--- .../mc/otm/client/AndroidMenuKeyMapping.kt | 6 +++--- .../mc/otm/client/ClientEventHandler.kt | 12 +++++------ .../mc/otm/client/ClientTickHandler.kt | 12 +++++------ .../dbotthepony/mc/otm/client/MatteryGUI.kt | 8 ++++---- .../mc/otm/client/MatteryTooltipComponents.kt | 4 ++-- .../mc/otm/client/render/ChartRendering.kt | 2 +- .../mc/otm/client/render/ShockwaveRenderer.kt | 2 +- .../client/render/blockentity/BankRenderer.kt | 4 ++-- .../mc/otm/compat/curios/CuriosCompat.kt | 6 +----- .../mc/otm/compat/vanilla/MatteryChestMenu.kt | 2 +- .../mc/otm/data/FlywheelMaterials.kt | 6 +++--- .../mc/otm/data/world/DecimalProvider.kt | 2 +- .../mc/otm/entity/SpawnModifiers.kt | 3 +-- .../mc/otm/item/ChestUpgraderItem.kt | 2 +- .../otm/item/PortableCondensationDriveItem.kt | 2 +- .../mc/otm/item/QuantumBatteryItem.kt | 4 ++-- .../mc/otm/item/armor/TritaniumArmorItem.kt | 2 +- .../mc/otm/item/consumables/NotNormalFood.kt | 2 +- .../mc/otm/item/tool/ExplosiveHammerItem.kt | 2 +- .../otm/item/tool/RedstoneInteractorItem.kt | 2 +- .../mc/otm/matter/AbstractRegistryAction.kt | 2 +- .../mc/otm/matter/IMatterFunction.kt | 2 +- .../mc/otm/matter/MatterManager.kt | 12 +++++------ .../mc/otm/player/MatteryPlayer.kt | 20 +++++++++---------- .../android/AndroidResearchDescription.kt | 4 ++-- .../player/android/AndroidResearchManager.kt | 4 ++-- .../player/android/AndroidResearchResult.kt | 4 ++-- .../android/feature/EnderTeleporterFeature.kt | 2 +- .../mc/otm/registry/CommandArgumentTypes.kt | 2 +- .../mc/otm/registry/MCriteriaTriggers.kt | 3 +-- .../dbotthepony/mc/otm/registry/MRegistry.kt | 2 +- .../mc/otm/registry/MStructureTags.kt | 4 ++-- .../mc/otm/registry/data/LootModifiers.kt | 2 +- .../mc/otm/registry/data/MHeightProviders.kt | 2 +- .../otm/registry/data/MItemFunctionTypes.kt | 2 +- .../otm/registry/data/MLootItemConditions.kt | 2 +- .../otm/registry/data/MLootNumberProviders.kt | 2 +- .../otm/registry/data/MPlacementModifiers.kt | 2 +- .../mc/otm/registry/data/MWorldGenFeatures.kt | 2 +- .../mc/otm/registry/game/AndroidFeatures.kt | 2 +- .../mc/otm/registry/game/MArmorMaterials.kt | 2 +- .../mc/otm/registry/game/MBlockColors.kt | 2 +- .../mc/otm/registry/game/MBlockEntities.kt | 2 +- .../mc/otm/registry/game/MBlocks.kt | 2 +- .../mc/otm/registry/game/MCreativeTabs.kt | 11 ++++++++-- .../otm/registry/game/MDataComponentTypes.kt | 2 +- .../mc/otm/registry/game/MEntityTypes.kt | 2 +- .../mc/otm/registry/game/MFluids.kt | 2 +- .../mc/otm/registry/game/MItems.kt | 2 +- .../mc/otm/registry/game/MMenus.kt | 2 +- .../mc/otm/registry/game/MRecipes.kt | 2 +- .../mc/otm/registry/game/MSoundEvents.kt | 2 +- .../mc/otm/registry/game/MStats.kt | 2 +- .../ru/dbotthepony/mc/otm/server/MCommands.kt | 2 +- .../mc/otm/storage/StorageStack.kt | 2 +- .../mc/otm/triggers/KillAsAndroidTrigger.kt | 2 +- 62 files changed, 121 insertions(+), 121 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt index 7225eb4a8..a2ab1da3f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt @@ -118,7 +118,7 @@ val isPaused: Boolean get() { return isPausedImpl } -fun recordClientThread() { +internal fun recordClientThread() { clientThreads.add(Thread.currentThread()) } @@ -186,19 +186,19 @@ var SERVER_IS_LIVE = false private val LOGGER = LogManager.getLogger() -fun onServerTickPre(event: ServerTickEvent.Pre) { +internal fun onServerTickPre(event: ServerTickEvent.Pre) { preServerTick.tick() serverThreads.add(Thread.currentThread()) } -fun onServerTickPost(event: ServerTickEvent.Post) { +internal fun onServerTickPost(event: ServerTickEvent.Post) { postServerTick.tick() // чтоб не плодить кучу подписчиков, вызовем напрямую отсюда GraphNodeList.tick() AbstractProfiledStorage.onServerPostTick() } -fun onLevelTickPre(event: LevelTickEvent.Pre) { +internal fun onLevelTickPre(event: LevelTickEvent.Pre) { preWorldTick[event.level]?.tick() if (event.level.isClientSide) { @@ -208,7 +208,7 @@ fun onLevelTickPre(event: LevelTickEvent.Pre) { } } -fun onLevelTickPost(event: LevelTickEvent.Post) { +internal fun onLevelTickPost(event: LevelTickEvent.Post) { postWorldTick[event.level]?.tick() } @@ -310,7 +310,7 @@ private fun clear() { postWorldTick.clear() } -fun onServerStarting(event: ServerAboutToStartEvent) { +internal fun onServerStarting(event: ServerAboutToStartEvent) { clear() SERVER_IS_LIVE = true _server = event.server @@ -318,13 +318,13 @@ fun onServerStarting(event: ServerAboutToStartEvent) { serverCounter.incrementAndGet() } -fun onServerStopping(event: ServerStoppingEvent) { +internal fun onServerStopping(event: ServerStoppingEvent) { clear() SERVER_IS_LIVE = false serverCounter.incrementAndGet() } -fun onServerStopped(event: ServerStoppedEvent) { +internal 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!") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt index dd23eeaef..caddadd36 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt @@ -153,7 +153,6 @@ object OverdriveThatMatters { MOD_BUS.addListener(EventPriority.NORMAL, TritaniumArmorModel::register) MOD_BUS.addListener(EventPriority.NORMAL, GravitationStabilizerModel::register) MOD_BUS.addListener(EventPriority.NORMAL, BreadMonsterModel::register) - MOD_BUS.addListener(EventPriority.NORMAL, MCreativeTabs::register) MOD_BUS.addListener(EventPriority.NORMAL, BatteryBankRenderer.Companion::onRegisterAdditionalModels) MOD_BUS.addListener(EventPriority.NORMAL, MatterBatteryBankRenderer.Companion::onRegisterAdditionalModels) 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 ab8ad4363..49fb486f3 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 @@ -633,18 +633,18 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } - fun onLevelUnload(event: LevelEvent.Unload) { + internal fun onLevelUnload(event: LevelEvent.Unload) { val level = event.level as? ServerLevel ?: return playerMap.remove(level) tickingMap.remove(level) } - fun onServerStopping(event: ServerStoppingEvent) { + internal fun onServerStopping(event: ServerStoppingEvent) { playerMap.clear() tickingMap.clear() } - fun postLevelTick(event: LevelTickEvent.Post) { + internal fun postLevelTick(event: LevelTickEvent.Post) { val level = event.level as? ServerLevel ?: return tickingMap[level]?.forEach { @@ -663,14 +663,14 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } - fun onWatch(event: ChunkWatchEvent.Watch) { + internal fun onWatch(event: ChunkWatchEvent.Watch) { playerMap .computeIfAbsent(event.level) { Long2ObjectOpenHashMap() } .computeIfAbsent(event.pos.toLong(), Long2ObjectFunction { ChunkSubscribers(event.level, it) }) .subscribe(event.player) } - fun onForget(event: ChunkWatchEvent.UnWatch) { + internal fun onForget(event: ChunkWatchEvent.UnWatch) { val levelMap = playerMap[event.level] ?: return val subs = levelMap.get(event.pos.toLong()) ?: return @@ -679,7 +679,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } - fun playerDisconnected(event: PlayerEvent.PlayerLoggedOutEvent) { + internal fun playerDisconnected(event: PlayerEvent.PlayerLoggedOutEvent) { for (tree in playerMap.values) { tree.values.removeIf { it.unsubscribe(event.entity as ServerPlayer) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/DevChestBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/DevChestBlockEntity.kt index 87b0cd7c8..b532e681a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/DevChestBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/DevChestBlockEntity.kt @@ -59,7 +59,7 @@ class DevChestBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryB return cache } - fun mappingsChanged(event: IdMappingEvent) { + internal fun mappingsChanged(event: IdMappingEvent) { cache.clear() } } 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 6b18ec9dd..6d11308d7 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 @@ -118,7 +118,7 @@ object DrivePool { } } - fun onWorldSave(event: LevelEvent.Save) { + internal fun onWorldSave(event: LevelEvent.Save) { writeBacklog(event.level.server!!.registryAccess()) } 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 8218c4dd3..09b20c886 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt @@ -46,7 +46,7 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl } } - fun onRenderGuiEvent(event: RenderGuiEvent.Post) { + internal fun onRenderGuiEvent(event: RenderGuiEvent.Post) { if (!isDown) { return } @@ -73,7 +73,7 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl } } - fun onRenderLevel(event: RenderLevelStageEvent) { + internal fun onRenderLevel(event: RenderLevelStageEvent) { if (!isDown) { return } @@ -92,7 +92,7 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl } } - fun register(event: RegisterKeyMappingsEvent) { + internal fun register(event: RegisterKeyMappingsEvent) { event.register(this) } } 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 70144d851..c7db0d6c0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt @@ -94,7 +94,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon } } - fun onMouseClick(event: InputEvent.MouseButton.Pre) { + internal 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 @@ -311,7 +311,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon const val COOLDOWN_ICON_SIZE = 18f const val COOLDOWN_ICON_MARGIN = 12f - fun onRenderGuiEvent(event: RenderGuiEvent.Post) { + internal fun onRenderGuiEvent(event: RenderGuiEvent.Post) { if (!grabbedInput) { lastRender = milliTimeD renderRegular(event) @@ -325,7 +325,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon } } - fun register(event: RegisterKeyMappingsEvent) { + internal fun register(event: RegisterKeyMappingsEvent) { event.register(this) } } 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 e6b4e9539..c16fac903 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -38,7 +38,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures import java.util.WeakHashMap -fun onMovementInputUpdate(event: MovementInputUpdateEvent) { +internal fun onMovementInputUpdate(event: MovementInputUpdateEvent) { val ply = event.entity val input = event.input @@ -198,7 +198,7 @@ private fun exosuitInventoryLogic(screen: Screen, addListener: (GuiEventListener scrollbar.scroll = inventoryScroll } -fun onMouseDragged(event: ScreenEvent.MouseDragged.Pre) { +internal fun onMouseDragged(event: ScreenEvent.MouseDragged.Pre) { val screen = minecraft.screen as? AbstractContainerScreen<*> ?: return if (screen is MatteryScreen<*>) @@ -214,7 +214,7 @@ fun onMouseDragged(event: ScreenEvent.MouseDragged.Pre) { } } -fun onMouseScrolled(event: ScreenEvent.MouseScrolled.Pre) { +internal fun onMouseScrolled(event: ScreenEvent.MouseScrolled.Pre) { val screen = minecraft.screen as? AbstractContainerScreen<*> ?: return if (screen is MatteryScreen<*>) @@ -242,7 +242,7 @@ fun onMouseScrolled(event: ScreenEvent.MouseScrolled.Pre) { } } -fun onPostScreenInit(event: ScreenEvent.Init.Post) { +internal fun onPostScreenInit(event: ScreenEvent.Init.Post) { if (!LOGGED_IN) return inventoryLogic(event) onceClient { @@ -250,7 +250,7 @@ fun onPostScreenInit(event: ScreenEvent.Init.Post) { } } -fun onScreenOpen(event: ScreenEvent.Opening) { +internal fun onScreenOpen(event: ScreenEvent.Opening) { if (shouldOpenVanillaInventory || minecraft.player?.isCreative == true) { return } @@ -266,7 +266,7 @@ private val TOOLTIP_TAG_DISPLAY_HELP = TranslatableComponent("otm.gui.debug.tags 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) { +internal fun tooltipEvent(event: ItemTooltipEvent) { if (event.flags.isAdvanced && ClientConfig.Tooltip.DISPLAY_TAGS && !event.itemStack.isEmpty) { val itemTags = ArrayList>() if (event.itemStack.tags.count() > 0) { 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 01ca2c77e..e760361c3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt @@ -33,7 +33,7 @@ private inline fun check(cond: Boolean, error: () -> String) { } } -fun createCursors() { +internal fun createCursors() { ARROW_CURSOR = GLFW.glfwCreateStandardCursor(GLFW.GLFW_ARROW_CURSOR) BEAM_CURSOR = GLFW.glfwCreateStandardCursor(GLFW.GLFW_IBEAM_CURSOR) HAND_CURSOR = GLFW.glfwCreateStandardCursor(GLFW.GLFW_POINTING_HAND_CURSOR) @@ -60,7 +60,7 @@ enum class CursorType(val pointer: LongSupplier) { } } -fun onClientPostRender(event: RenderFrameEvent.Post) { +internal fun onClientPostRender(event: RenderFrameEvent.Post) { if (MODIFIED_CURSOR_FRAMES-- <= 0 && MODIFIED_CURSOR) { GLFW.glfwSetCursor(minecraft.window.window, ARROW_CURSOR) MODIFIED_CURSOR = false @@ -116,22 +116,22 @@ fun tickWhileClientPre(condition: () -> Boolean, ticker: () -> Unit) { tickClientPre(IConditionalTickable.wrap(condition, ticker)) } -fun onClientTickPre(event: ClientTickEvent.Pre) { +internal fun onClientTickPre(event: ClientTickEvent.Pre) { preTickList.tick() } -fun onClientTickPost(event: ClientTickEvent.Post) { +internal fun onClientTickPost(event: ClientTickEvent.Post) { postTickList.tick() } -fun onClientDisconnected(event: ClientPlayerNetworkEvent.LoggingOut) { +internal fun onClientDisconnected(event: ClientPlayerNetworkEvent.LoggingOut) { LOGGED_IN = false preTickList.clear() postTickList.clear() } -fun onClientConnected(event: ClientPlayerNetworkEvent.LoggingIn) { +internal fun onClientConnected(event: ClientPlayerNetworkEvent.LoggingIn) { LOGGED_IN = true preTickList.clear() 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 e414af87d..b9fbe68db 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -48,7 +48,7 @@ object MatteryGUI { private val buttonShaker = Random() - fun onScreenRender(event: ScreenEvent.Render.Pre) { + internal fun onScreenRender(event: ScreenEvent.Render.Pre) { val screen = minecraft.screen as? InBedChatScreen if (screen == null || (screen.leaveBedButton as Button?) == null) { @@ -80,7 +80,7 @@ object MatteryGUI { } } - fun onOpenGUIEvent(event: ScreenEvent.Opening) { + internal fun onOpenGUIEvent(event: ScreenEvent.Opening) { originalBedButtonX = -1 originalBedButtonY = -1 @@ -95,7 +95,7 @@ object MatteryGUI { } } - fun onLayerRenderEvent(event: RenderGuiLayerEvent.Pre) { + internal fun onLayerRenderEvent(event: RenderGuiLayerEvent.Pre) { if (minecraft.player?.matteryPlayer?.isAndroid == true) { if (event.name == VanillaGuiLayers.FOOD_LEVEL || event.name == VanillaGuiLayers.AIR_LEVEL @@ -105,7 +105,7 @@ object MatteryGUI { } } - fun registerGuiLayers(event: RegisterGuiLayersEvent) { + internal fun registerGuiLayers(event: RegisterGuiLayersEvent) { event.registerBelow(VanillaGuiLayers.FOOD_LEVEL, loc("android_energy_bar"), AndroidEnergyBarLayer()) event.registerBelow(VanillaGuiLayers.PLAYER_HEALTH, loc("android_health_bar"), AndroidHealthBarLayer()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryTooltipComponents.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryTooltipComponents.kt index 3ba52c20a..68f5bf7d9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryTooltipComponents.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryTooltipComponents.kt @@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import kotlin.math.ceil object MatteryTooltipComponents { - fun gatherComponents(event: RenderTooltipEvent.GatherComponents) { + internal fun gatherComponents(event: RenderTooltipEvent.GatherComponents) { val energyCap = event.itemStack.getCapability(MatteryCapability.ITEM_ENERGY) if (energyCap != null && energyCap.maxBatteryLevel > Decimal.ZERO) { event.tooltipElements.add(1, Either.right(EnergyStorageGaugeTooltip(energyCap))) @@ -29,7 +29,7 @@ object MatteryTooltipComponents { } } - fun registerComponents(event: RegisterClientTooltipComponentFactoriesEvent) { + internal fun registerComponents(event: RegisterClientTooltipComponentFactoriesEvent) { event.register(EnergyStorageGaugeTooltip::class.java) { it } event.register(MatterStorageGaugeTooltip::class.java) { it } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ChartRendering.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ChartRendering.kt index 5dd925941..255d67751 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ChartRendering.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ChartRendering.kt @@ -79,7 +79,7 @@ class ChartTooltipElement( } companion object { - fun register(event: RegisterClientTooltipComponentFactoriesEvent) { + internal fun register(event: RegisterClientTooltipComponentFactoriesEvent) { event.register(ChartTooltipElement::class.java) { it } } } 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 7dddcfc17..6178ec9f9 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 @@ -63,7 +63,7 @@ object ShockwaveRenderer { private const val EXPANSION_PER_SECOND = 18f - fun onRender(event: RenderLevelStageEvent) { + internal fun onRender(event: RenderLevelStageEvent) { if (event.stage !== RenderLevelStageEvent.Stage.AFTER_TRANSLUCENT_BLOCKS) { return } 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 f66ef8676..daa1e37d5 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 @@ -142,7 +142,7 @@ class BatteryBankRenderer(context: BlockEntityRendererProvider.Context) : BankRe override val texture: AbstractMatterySprite = WidgetLocation.VERTICAL_GAUGES.sprite(x = 108f, width = 18f) companion object { - fun onRegisterAdditionalModels(event: ModelEvent.RegisterAdditional) { + internal fun onRegisterAdditionalModels(event: ModelEvent.RegisterAdditional) { for (i in 0 .. 11) { event.register(ModelResourceLocation.standalone(ResourceLocation(OverdriveThatMatters.MOD_ID, "block/battery/battery$i"))) } @@ -168,7 +168,7 @@ class MatterBatteryBankRenderer(context: BlockEntityRendererProvider.Context) : override val texture: AbstractMatterySprite = WidgetLocation.VERTICAL_GAUGES.sprite(x = 90f, width = 18f) companion object { - fun onRegisterAdditionalModels(event: ModelEvent.RegisterAdditional) { + internal fun onRegisterAdditionalModels(event: ModelEvent.RegisterAdditional) { for (i in 0 .. 11) { event.register(ModelResourceLocation.standalone(ResourceLocation(OverdriveThatMatters.MOD_ID, "block/battery/matter_capacitor$i"))) } 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 45b9341f9..34c6e904c 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 @@ -40,15 +40,11 @@ val isCuriosLoaded by lazy { ModList.get().isLoaded(CuriosApi.MODID) } -fun onCuriosSlotModifiersUpdated(event: SlotModifiersUpdatedEvent) { +internal fun onCuriosSlotModifiersUpdated(event: SlotModifiersUpdatedEvent) { check(isCuriosLoaded) { "Curios is not loaded!" } event.entity.matteryPlayer?.recreateExoPackMenu() } -fun openCuriosScreen(carriedStack: ItemStack = ItemStack.EMPTY) { - if (FMLEnvironment.dist.isClient) PacketDistributor.sendToServer(CPacketOpenCurios(carriedStack)) -} - private fun Player.getCuriosSlotsImpl(): List> { val handler = getCapability(CuriosCapability.INVENTORY) ?: return listOf() 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 d5ef52363..42762af85 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 @@ -99,7 +99,7 @@ class MatteryChestMenu( return MatteryChestMenu(HOPPER, containerId, inventory, 1, 5, container) } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registrar.register(bus) bus.addListener(this::registerScreens) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/FlywheelMaterials.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/FlywheelMaterials.kt index 51ef535fc..c2cbf6141 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/FlywheelMaterials.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/FlywheelMaterials.kt @@ -198,7 +198,7 @@ object FlywheelMaterials : SimpleJsonResourceReloadListener(GsonBuilder().setPre ).apply(it, ::Entry) } - fun reloadEvent(event: AddReloadListenerEvent) { + internal fun reloadEvent(event: AddReloadListenerEvent) { event.addListener(this) } @@ -227,7 +227,7 @@ object FlywheelMaterials : SimpleJsonResourceReloadListener(GsonBuilder().setPre } } - fun onDataPackSync(event: OnDatapackSyncEvent) { + internal fun onDataPackSync(event: OnDatapackSyncEvent) { if (event.player == null) { PacketDistributor.sendToAllPlayers(SyncPacket(elements)) } else { @@ -235,7 +235,7 @@ object FlywheelMaterials : SimpleJsonResourceReloadListener(GsonBuilder().setPre } } - fun tooltipEvent(event: ItemTooltipEvent) { + internal fun tooltipEvent(event: ItemTooltipEvent) { if (minecraft.window.isShiftDown) { val item = event.itemStack.item diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/world/DecimalProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/world/DecimalProvider.kt index aa917f726..bdda35e24 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/world/DecimalProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/world/DecimalProvider.kt @@ -52,7 +52,7 @@ abstract class DecimalProvider : SampledDecimal { registror.register("uniform") { UniformDecimal } } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { bus.addListener(registryHolder::build) registror.register(bus) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt index c40ff4f28..27a843a12 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/SpawnModifiers.kt @@ -12,8 +12,7 @@ import ru.dbotthepony.mc.otm.registry.game.MItems object WitheredSkeletonSpawnHandler { - @SubscribeEvent - fun onEntityJoin(event: EntityJoinLevelEvent) { + internal fun onEntityJoin(event: EntityJoinLevelEvent) { val entity = event.entity if (entity is WitherSkeleton) { 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 855e63ea2..6bd0e3f4d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt @@ -106,7 +106,7 @@ class ChestUpgraderItem : MatteryItem(Properties().stacksTo(1)) { } companion object { - fun onEntityInteract(event: PlayerInteractEvent.EntityInteract) { + internal fun onEntityInteract(event: PlayerInteractEvent.EntityInteract) { if (event.target !is MinecartChest) return val offhand = if (event.entity.getItemInHand(InteractionHand.MAIN_HAND).item is ChestUpgraderItem) { 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 1591ac8ac..c23e65dee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt @@ -68,7 +68,7 @@ class PortableCondensationDriveItem(capacity: Int) : Item(Properties().stacksTo( const val MAX_FILTERS = 4 * 3 private val EMPTY_FILTER = ItemFilter(MAX_FILTERS) - fun onPickupEvent(event: ItemEntityPickupEvent.Pre) { + internal fun onPickupEvent(event: ItemEntityPickupEvent.Pre) { if (event.itemEntity.owner != null && event.itemEntity.owner != event.player && event.itemEntity.age < 200 || event.itemEntity.item.isEmpty) { return } 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 9219a8248..5e2ba1f97 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -317,7 +317,7 @@ class QuantumBatteryItem(val savedataID: String, val balanceValues: EnergyBalanc } companion object { - fun clientDisconnect(event: ClientPlayerNetworkEvent.LoggingOut) { + internal fun clientDisconnect(event: ClientPlayerNetworkEvent.LoggingOut) { BuiltInRegistries.ITEM.forEach { if (it is QuantumBatteryItem) it.clientData.clear() } } @@ -331,7 +331,7 @@ class QuantumBatteryItem(val savedataID: String, val balanceValues: EnergyBalanc ) } - fun tick(event: ServerTickEvent.Post) { + internal fun tick(event: ServerTickEvent.Post) { for (ply in event.server.playerList.players) { val networkedChannels = ObjectOpenHashSet(0) 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 3f3235986..19f72bffe 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 @@ -53,7 +53,7 @@ class TritaniumArmorItem(slot: Type) : ArmorItem(MArmorMaterials.TRITANIUM, slot val TEXTURE_LOCATION_BASE = loc("textures/models/armor/tritanium_armor_base.png") val TEXTURE_LOCATION_OVERLAY = loc("textures/models/armor/tritanium_armor_overlay.png") - fun onHurt(event: LivingIncomingDamageEvent) { + internal fun onHurt(event: LivingIncomingDamageEvent) { 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 } && diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/NotNormalFood.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/NotNormalFood.kt index 130ecdfb0..106e3e0ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/NotNormalFood.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/consumables/NotNormalFood.kt @@ -107,7 +107,7 @@ class NotNormalFood( } companion object { - fun onInteract(event: EntityInteract) { + internal fun onInteract(event: EntityInteract) { val item = event.itemStack.item as? NotNormalFood ?: return val target = event.target as? LivingEntity ?: return 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 018d1d474..624f890ff 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 @@ -321,7 +321,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) val GUNPOWDER_PREDICATE = Predicate { stack: ItemStack -> stack.`is`(Tags.Items.GUNPOWDERS) } val IRON_NUGGET_PREDICATE = Predicate { stack: ItemStack -> stack.`is`(Tags.Items.NUGGETS_IRON) } - fun onLeftClickBlock(event: PlayerInteractEvent.LeftClickBlock) { + internal fun onLeftClickBlock(event: PlayerInteractEvent.LeftClickBlock) { val item = event.itemStack.item if (item is ExplosiveHammerItem) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/RedstoneInteractorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/RedstoneInteractorItem.kt index b444749c5..2007269da 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/RedstoneInteractorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/RedstoneInteractorItem.kt @@ -122,7 +122,7 @@ class RedstoneInteractorItem : MatteryItem(Properties().stacksTo(1)) { return -1 } - fun onUse(event: UseItemOnBlockEvent) { + internal fun onUse(event: UseItemOnBlockEvent) { if (event.itemStack.item is RedstoneInteractorItem) { if ((event.itemStack.item as RedstoneInteractorItem).useOn(event.useOnContext).consumesAction()) event.cancelWithResult(ItemInteractionResult.sidedSuccess(event.level.isClientSide())) 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 69147d98b..a72d7c944 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/AbstractRegistryAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/AbstractRegistryAction.kt @@ -114,7 +114,7 @@ abstract class AbstractRegistryAction( registrar.register("blacklist") { BlacklistAction.Companion } } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registrar.register(bus) bus.addListener(registryDelegate::build) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterFunction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterFunction.kt index 4c6e670e9..b7e64a2d0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterFunction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterFunction.kt @@ -36,7 +36,7 @@ interface IMatterFunction { 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 }) } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registrar.register(bus) bus.addListener(registryDelegate::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 176860e2c..828868a1f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -1334,7 +1334,7 @@ object MatterManager { 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) { + internal fun tooltipEvent(event: ItemTooltipEvent) { if (ClientConfig.Tooltip.ALWAYS_DISPLAY_MATTER_VALUE || minecraft.window.isShiftDown) { val matter = get(event.itemStack, accountForStackSize = false) @@ -1527,12 +1527,12 @@ object MatterManager { } } - fun reloadEvent(event: AddReloadListenerEvent) { + internal fun reloadEvent(event: AddReloadListenerEvent) { event.addListener(Registry) event.addListener(Resolver) } - fun initialize(bus: IEventBus) { + internal fun initialize(bus: IEventBus) { bus.addListener(Resolver.delegate::build) Resolver.registrar.register(bus) } @@ -1632,7 +1632,7 @@ object MatterManager { return 0 } - fun addCommands(event: RegisterCommandsEvent) { + internal fun addCommands(event: RegisterCommandsEvent) { event.dispatcher.register( Commands.literal("dump_matter_registry") .requires { it.hasPermission(Commands.LEVEL_OWNERS) } @@ -1685,7 +1685,7 @@ object MatterManager { syncRegistry(server.registryAccess(), PacketDistributor::sendToAllPlayers) } - fun onDataPackSync(event: OnDatapackSyncEvent) { + internal fun onDataPackSync(event: OnDatapackSyncEvent) { if (!registryIsBuilt) return @@ -1696,7 +1696,7 @@ object MatterManager { } } - fun onServerStarted(event: ServerStartedEvent) { + internal 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) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt index 99e72ad24..366b86900 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryPlayer.kt @@ -1340,7 +1340,7 @@ class MatteryPlayer(val ply: Player) { val ANDROID_IMMUNE_EFFECTS: TagKey = TagKey.create(BuiltInRegistries.MOB_EFFECT.key(), ResourceLocation(OverdriveThatMatters.MOD_ID, "android_immune_effects")) - fun onPlayerTickPre(event: PlayerTickEvent.Pre) { + internal fun onPlayerTickPre(event: PlayerTickEvent.Pre) { val ent = event.entity if (!ent.level().isClientSide) { @@ -1348,7 +1348,7 @@ class MatteryPlayer(val ply: Player) { } } - fun onPlayerTickPost(event: PlayerTickEvent.Pre) { + internal fun onPlayerTickPost(event: PlayerTickEvent.Pre) { val ent = event.entity if (ent.level().isClientSide) { @@ -1358,7 +1358,7 @@ class MatteryPlayer(val ply: Player) { } } - fun isMobEffectApplicable(event: MobEffectEvent.Applicable) { + internal fun isMobEffectApplicable(event: MobEffectEvent.Applicable) { event.entity.matteryPlayer?.let { if (it.isAndroid && BuiltInRegistries.MOB_EFFECT.getOrCreateTag(ANDROID_IMMUNE_EFFECTS).any { it == event.effectInstance?.effect }) { event.result = MobEffectEvent.Applicable.Result.DO_NOT_APPLY @@ -1366,18 +1366,18 @@ class MatteryPlayer(val ply: Player) { } } - fun onHurtEvent(event: LivingIncomingDamageEvent) { + internal fun onHurtEvent(event: LivingIncomingDamageEvent) { event.entity.matteryPlayer?.onHurt(event) } - fun onPlayerChangeDimensionEvent(event: PlayerEvent.PlayerChangedDimensionEvent) { + internal fun onPlayerChangeDimensionEvent(event: PlayerEvent.PlayerChangedDimensionEvent) { onceServer { event.entity.matteryPlayer.invalidateNetworkState() event.entity.matteryPlayer.recreateExoPackMenu() } } - fun onPlayerDeath(event: LivingDeathEvent) { + internal fun onPlayerDeath(event: LivingDeathEvent) { val ply = event.entity as? Player ?: return if (ply.matteryPlayer.lastDeathTick != ply.tickCount) { @@ -1402,7 +1402,7 @@ class MatteryPlayer(val ply: Player) { } } - fun onPlayerCloneEvent(event: PlayerEvent.Clone) { + internal fun onPlayerCloneEvent(event: PlayerEvent.Clone) { val it = event.entity.matteryPlayer val original = event.original.matteryPlayer @@ -1430,7 +1430,7 @@ class MatteryPlayer(val ply: Player) { private val LOGGER = LogManager.getLogger() - fun onPlayerSpawnPhantoms(event: PlayerSpawnPhantomsEvent) { + internal fun onPlayerSpawnPhantoms(event: PlayerSpawnPhantomsEvent) { if (event.entity.matteryPlayer.isAndroid) { event.result = PlayerSpawnPhantomsEvent.Result.DENY } @@ -1531,7 +1531,7 @@ class MatteryPlayer(val ply: Player) { PacketDistributor.sendToServer(PickItemFromInventoryPacket(targetSlot, itemSlot)) } - fun onStartTracking(event: PlayerEvent.StartTracking) { + internal fun onStartTracking(event: PlayerEvent.StartTracking) { if (event.target is ServerPlayer) { (event.target as ServerPlayer).matteryPlayer.let { it.remoteSynchers[event.entity as ServerPlayer] = it.publicSyncher.Remote() @@ -1539,7 +1539,7 @@ class MatteryPlayer(val ply: Player) { } } - fun onStopTracking(event: PlayerEvent.StopTracking) { + internal fun onStopTracking(event: PlayerEvent.StopTracking) { if (event.target is ServerPlayer) { (event.target as ServerPlayer).matteryPlayer.remoteSynchers.remove(event.entity as ServerPlayer) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchDescription.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchDescription.kt index 2afc8d9dc..b1774f198 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchDescription.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchDescription.kt @@ -23,7 +23,7 @@ object AndroidResearchDescriptions { registrar.register("plain") { PlainAndroidResearchDescription } } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registrar.register(bus) } @@ -149,7 +149,7 @@ interface AndroidResearchDescription { registry.byNameCodec().dispatch({ it.type }, { it.codec }) } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { bus.addListener(delegate::build) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchManager.kt index 786dd17bc..eaaeb6ef4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchManager.kt @@ -93,11 +93,11 @@ object AndroidResearchManager : SimpleJsonResourceReloadListener(GsonBuilder().s } } - fun reloadEvent(event: AddReloadListenerEvent) { + internal fun reloadEvent(event: AddReloadListenerEvent) { event.addListener(this) } - fun syncEvent(event: OnDatapackSyncEvent) { + internal fun syncEvent(event: OnDatapackSyncEvent) { val packet = SyncPacket(researchMap.values) if (event.player != null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchResult.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchResult.kt index 41043c82d..6e908a33f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchResult.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/AndroidResearchResult.kt @@ -55,7 +55,7 @@ object AndroidResearchResults { 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 } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registrar.register(bus) } } @@ -162,7 +162,7 @@ interface AndroidResearchResult { registry.byNameCodec().dispatch({ it.type }, { it.codec }) } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { bus.addListener(delegate::build) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/EnderTeleporterFeature.kt index 2f0bd1cbf..23975234c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/android/feature/EnderTeleporterFeature.kt @@ -392,7 +392,7 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A val SPRITE = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/item/black_hole.png").sprite(0f, 0f, 16f, 16f, 16f, 16f) - fun onEntityDeath(event: LivingDeathEvent) { + internal 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/registry/CommandArgumentTypes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CommandArgumentTypes.kt index 5c6e73824..30eeee740 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CommandArgumentTypes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CommandArgumentTypes.kt @@ -14,7 +14,7 @@ object CommandArgumentTypes { ArgumentTypeInfos.registerByClass(AndroidResearchArgument::class.java, SingletonArgumentInfo.contextFree(AndroidResearchArgument.Companion::create)) } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registry.register(bus) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCriteriaTriggers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCriteriaTriggers.kt index 200f7f3c4..a097b2137 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCriteriaTriggers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCriteriaTriggers.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.registry -import net.minecraft.advancements.CriteriaTriggers import net.minecraft.core.registries.BuiltInRegistries import net.neoforged.bus.api.IEventBus import ru.dbotthepony.mc.otm.triggers.AndroidBatteryTrigger @@ -29,7 +28,7 @@ import ru.dbotthepony.mc.otm.triggers.TakeItemOutOfReplicatorTrigger object MCriteriaTriggers { private val registrar = MDeferredRegister(BuiltInRegistries.TRIGGER_TYPES) - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registrar.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 e117ad120..719d54efe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -250,7 +250,7 @@ object MRegistry : IBlockItemRegistryAcceptor { }*/ } - fun initialize(bus: IEventBus) { + internal fun initialize(bus: IEventBus) { bus.addListener(features::build) bus.addListener(this::initializeClient) bus.addListener(this::initializeCommon) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MStructureTags.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MStructureTags.kt index 734dcd587..abd8f311d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MStructureTags.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MStructureTags.kt @@ -14,11 +14,11 @@ object MStructureTags { val FIELD_RESEARCH_PODS = create("field_research_pods") val WRECKAGES = create("wreckages") - fun create(location: String): TagKey { + private fun create(location: String): TagKey { return TagKey.create(Registries.STRUCTURE, loc(location)) } - fun registerVillagerTrades(event: VillagerTradesEvent) { + internal fun registerVillagerTrades(event: VillagerTradesEvent) { if (event.type == VillagerProfession.CARTOGRAPHER) { with (event.trades.get(2)) { add(VillagerTrades.TreasureMapForEmeralds(10, WRECKAGES, "filled_map.otm_wreckage", diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/LootModifiers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/LootModifiers.kt index d6e65ed9b..88d2e70fa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/LootModifiers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/LootModifiers.kt @@ -13,7 +13,7 @@ object LootModifiers { registry.register("loot_appender") { LootPoolAppender.CODEC } } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registry.register(bus) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MHeightProviders.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MHeightProviders.kt index 92b860932..d291621d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MHeightProviders.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MHeightProviders.kt @@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.registry.MDeferredRegister object MHeightProviders { private val registry = MDeferredRegister(BuiltInRegistries.HEIGHT_PROVIDER_TYPE) - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registry.register(bus) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MItemFunctionTypes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MItemFunctionTypes.kt index d03ace15b..d19ca25b7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MItemFunctionTypes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MItemFunctionTypes.kt @@ -19,7 +19,7 @@ object MItemFunctionTypes { val PROCEDURAL_EXOPACK_UPGRADE by registry.register("exopack_upgrade") { LootItemFunctionType(ProceduralExopackSlotUpgradeItem.Randomizer.CODEC) } val MATTER_DUST by registry.register("matter_dust") { LootItemFunctionType(MatterDustItem.Randomizer.CODEC) } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registry.register(bus) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MLootItemConditions.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MLootItemConditions.kt index 9b17e7a55..34e2b3cdb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MLootItemConditions.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MLootItemConditions.kt @@ -23,7 +23,7 @@ object MLootItemConditions { 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) } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registry.register(bus) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MLootNumberProviders.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MLootNumberProviders.kt index 7165eebbd..93619c404 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MLootNumberProviders.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MLootNumberProviders.kt @@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.registry.MDeferredRegister object MLootNumberProviders { private val registry = MDeferredRegister(BuiltInRegistries.LOOT_NUMBER_PROVIDER_TYPE, OverdriveThatMatters.MOD_ID) - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registry.register(bus) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MPlacementModifiers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MPlacementModifiers.kt index bfb73a091..82f302b39 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MPlacementModifiers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MPlacementModifiers.kt @@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.registry.MDeferredRegister object MPlacementModifiers { private val registry = MDeferredRegister(BuiltInRegistries.PLACEMENT_MODIFIER_TYPE) - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registry.register(bus) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MWorldGenFeatures.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MWorldGenFeatures.kt index 04d3ce732..dc15e0189 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MWorldGenFeatures.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MWorldGenFeatures.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.worldgen.feature.BlackHolePlacerFeature object MWorldGenFeatures { private val registry = MDeferredRegister(BuiltInRegistries.FEATURE) - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registry.register(bus) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/AndroidFeatures.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/AndroidFeatures.kt index f3ad0df38..9e1c1d460 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/AndroidFeatures.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/AndroidFeatures.kt @@ -38,7 +38,7 @@ object AndroidFeatures { val JUMP_BOOST by registry.register(MNames.JUMP_BOOST) { AndroidFeatureType(::JumpBoostFeature) } val ENDER_TELEPORTER by registry.register(MNames.ENDER_TELEPORTER) { AndroidFeatureType(::EnderTeleporterFeature) } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registry.register(bus) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MArmorMaterials.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MArmorMaterials.kt index c024c2d90..747c82107 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MArmorMaterials.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MArmorMaterials.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.registry.MItemTags object MArmorMaterials { private val registrar = MDeferredRegister(BuiltInRegistries.ARMOR_MATERIAL) - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registrar.register(bus) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MBlockColors.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MBlockColors.kt index 60c2a4d7b..b67a13937 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MBlockColors.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MBlockColors.kt @@ -64,7 +64,7 @@ object MBlockColors { event.register(HoloSightColor, MBlocks.HOLO_SIGN) } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { bus.addListener(this::registerBlockColors) bus.addListener(this::registerItemColors) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MBlockEntities.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MBlockEntities.kt index 41c02d5b1..021700c52 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MBlockEntities.kt @@ -118,7 +118,7 @@ object MBlockEntities { val HOLO_SIGN: BlockEntityType by registry.register(MNames.HOLO_SIGN) { BlockEntityType.Builder.of(::HoloSignBlockEntity, MBlocks.HOLO_SIGN).build(null) } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registry.register(bus) bus.addListener(this::registerClient) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MBlocks.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MBlocks.kt index 9e4399b47..33d27ca12 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MBlocks.kt @@ -136,7 +136,7 @@ object MBlocks { } } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registry.register(bus) bus.addListener(MBlocks::registerCapabilities) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MCreativeTabs.kt index 4d1f4f08d..158c6295e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MCreativeTabs.kt @@ -8,6 +8,8 @@ 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.neoforged.api.distmarker.Dist +import net.neoforged.bus.api.EventPriority import net.neoforged.bus.api.IEventBus import net.neoforged.neoforge.capabilities.Capabilities import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent @@ -23,6 +25,7 @@ import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator import ru.dbotthepony.mc.otm.registry.MDeferredRegister import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.registry.game.MItems.BATTERY_CREATIVE +import thedarkcolour.kotlinforforge.neoforge.forge.DIST private fun CreativeModeTab.Output.accept(values: Collection) { for (item in values) { @@ -394,11 +397,15 @@ object MCreativeTabs { .build() } - fun initialize(bus: IEventBus) { + internal fun initialize(bus: IEventBus) { registry.register(bus) + + if (DIST == Dist.CLIENT) { + bus.addListener(EventPriority.NORMAL, ::register) + } } - fun register(event: BuildCreativeModeTabContentsEvent) { + private fun register(event: BuildCreativeModeTabContentsEvent) { CreativeMenuItemComparator.invalidate() when (event.tab) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MDataComponentTypes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MDataComponentTypes.kt index 4459e52e0..fbf77afc9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MDataComponentTypes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MDataComponentTypes.kt @@ -117,7 +117,7 @@ object MDataComponentTypes { Configurator } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registry.register(bus) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MEntityTypes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MEntityTypes.kt index ebfa596c4..1bd68c710 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MEntityTypes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MEntityTypes.kt @@ -68,7 +68,7 @@ object MEntityTypes { } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registry.register(bus) bus.addListener(this::registerAttributes) bus.addListener(this::registerClient) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MFluids.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MFluids.kt index 7ceab0611..a7f8efc3a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MFluids.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MFluids.kt @@ -19,7 +19,7 @@ object MFluids { private val types = MDeferredRegister(NeoForgeRegistries.FLUID_TYPES.key()) private val fluids = MDeferredRegister(BuiltInRegistries.FLUID) - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { types.register(bus) fluids.register(bus) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MItems.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MItems.kt index c0bc06fe3..622cf8a9e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MItems.kt @@ -86,7 +86,7 @@ object MItems { return registry.coloredWithBase(name) { color -> BlockItem(blocks[color]!!, properties) } } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registry.register(bus) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MMenus.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MMenus.kt index 5c0011609..9de020be1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MMenus.kt @@ -130,7 +130,7 @@ object MMenus { val STORAGE_IMPORTER_EXPORTER by registry.register(MNames.STORAGE_IMPORTER) { MenuType(::StorageImporterExporterMenu, FeatureFlags.VANILLA_SET) } val STORAGE_POWER_SUPPLIER by registry.register(MNames.STORAGE_POWER_SUPPLIER) { MenuType(::StoragePowerSupplierMenu, FeatureFlags.VANILLA_SET) } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registry.register(bus) bus.addListener(this::registerScreens) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MRecipes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MRecipes.kt index ddf504cb2..f1312c23b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MRecipes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MRecipes.kt @@ -22,7 +22,7 @@ object MRecipes { private val types = MDeferredRegister(BuiltInRegistries.RECIPE_TYPE, OverdriveThatMatters.MOD_ID) private val serializers = MDeferredRegister(BuiltInRegistries.RECIPE_SERIALIZER, OverdriveThatMatters.MOD_ID) - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { types.register(bus) serializers.register(bus) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MSoundEvents.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MSoundEvents.kt index 04daae5ed..f2978152f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MSoundEvents.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MSoundEvents.kt @@ -27,7 +27,7 @@ object MSoundEvents { val LOADER_AMBIENT by make("loader_ambient") - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registry.register(bus) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MStats.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MStats.kt index 01076364a..acc1922a4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MStats.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/game/MStats.kt @@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.registry.StatNames.POWER_CONSUMED object MStats { private val registrar = MDeferredRegister(BuiltInRegistries.CUSTOM_STAT) - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { registrar.register(bus) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/server/MCommands.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/server/MCommands.kt index 8b911edb9..2f1d7cc22 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/server/MCommands.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/server/MCommands.kt @@ -4,7 +4,7 @@ import net.neoforged.neoforge.event.RegisterCommandsEvent import ru.dbotthepony.mc.otm.server.command.* object MCommands { - fun register(event: RegisterCommandsEvent) { + internal fun register(event: RegisterCommandsEvent) { ExopackCommand.register(event) AndroidCommand.register(event) } 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 e2e28eb23..0dfd65e2d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/StorageStack.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/StorageStack.kt @@ -130,7 +130,7 @@ abstract class StorageStack>(val count: BigInteger) { ) } - fun register(bus: IEventBus) { + internal fun register(bus: IEventBus) { bus.addListener(delegate::build) registrar.register(bus) } 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 35abe1315..23fe57ee2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt @@ -123,7 +123,7 @@ object KillAsAndroidTrigger : MCriterionTrigger(R playerPredicate: Optional = Optional.empty(), ) : AbstractInstance(playerPredicate) - fun onKill(event: LivingDeathEvent) { + internal fun onKill(event: LivingDeathEvent) { if (event.entity is ElderGuardian) { val killer = event.source.entity From 7f299a6dec2c525e32b7053746305a233581bf99 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Mar 2025 18:55:55 +0700 Subject: [PATCH 28/46] Provide Unit (singleton) codecs --- .../ru/dbotthepony/mc/otm/network/MatteryStreamCodec.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryStreamCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryStreamCodec.kt index aff3394b6..a217ec302 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryStreamCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryStreamCodec.kt @@ -35,6 +35,14 @@ interface MatteryStreamCodec : StreamCodec<@UnsafeVariance S, } } + class MUnit(val value: V) : MatteryStreamCodec { + override fun decode(stream: ByteBuf): V { + return value + } + + override fun encode(stream: ByteBuf, value: V) {} + } + abstract class AbstractPair(private val first: MatteryStreamCodec, private val second: MatteryStreamCodec) : MatteryStreamCodec { protected abstract fun getFirst(value: P): A protected abstract fun getSecond(value: P): B From 10f250b822d12fb49c6fd5ec1a2b167a0310b474 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Mar 2025 18:56:23 +0700 Subject: [PATCH 29/46] Provide convenient unit packet registration --- .../kotlin/ru/dbotthepony/mc/otm/network/Ext.kt | 12 ++++++++++++ .../mc/otm/network/MatteryPlayerPackets.kt | 13 ------------- .../ru/dbotthepony/mc/otm/network/NetworkPackets.kt | 12 ++++++------ 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/Ext.kt index b9d4f2bad..fe32ada33 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/Ext.kt @@ -28,6 +28,18 @@ fun PayloadRegistrar.playToServer( handler: KFunction1 ): PayloadRegistrar = playToServer(type, codec) { _, context -> handler(context) } +fun PayloadRegistrar.playToClient( + type: CustomPacketPayload.Type, + value: T, + handler: KFunction1 +): PayloadRegistrar = playToClient(type, MatteryStreamCodec.MUnit(value)) { _, context -> handler(context) } + +fun PayloadRegistrar.playToServer( + type: CustomPacketPayload.Type, + value: T, + handler: KFunction1 +): PayloadRegistrar = playToServer(type, MatteryStreamCodec.MUnit(value)) { _, context -> handler(context) } + inline fun encodePayload(registry: RegistryAccess, block: (RegistryFriendlyByteBuf) -> Unit): ByteArrayList { val underlying = ByteBufAllocator.DEFAULT.buffer() val buf = RegistryFriendlyByteBuf(underlying, registry, ConnectionType.NEOFORGE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt index 72b92aaf2..29bf837a9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerPackets.kt @@ -245,9 +245,6 @@ object ExopackMenuOpen : CustomPacketPayload { "exopack_menu_open" ) ) - - val CODEC: StreamCodec = - StreamCodec.ofMember({ _, _ -> }, { ExopackMenuOpen }) } class PickItemFromInventoryPacket( @@ -347,8 +344,6 @@ object DisplayExopackPacket : CustomPacketPayload { "display_exopack" ) ) - val CODEC: StreamCodec = - StreamCodec.ofMember({ _, _ -> }, { DisplayExopackPacket }) } object HideExopackPacket : CustomPacketPayload { @@ -366,8 +361,6 @@ object HideExopackPacket : CustomPacketPayload { "hide_exopack" ) ) - val CODEC: StreamCodec = - StreamCodec.ofMember({ _, _ -> }, { HideExopackPacket }) } object EnableExopackGlowPacket : CustomPacketPayload { @@ -385,8 +378,6 @@ object EnableExopackGlowPacket : CustomPacketPayload { "enable_exopack_glow" ) ) - val CODEC: StreamCodec = - StreamCodec.ofMember({ _, _ -> }, { EnableExopackGlowPacket }) } object DisableExopackGlowPacket : CustomPacketPayload { @@ -404,8 +395,6 @@ object DisableExopackGlowPacket : CustomPacketPayload { "disable_exopack_glow" ) ) - val CODEC: StreamCodec = - StreamCodec.ofMember({ _, _ -> }, { DisableExopackGlowPacket }) } object ResetExopackColorPacket : CustomPacketPayload { @@ -423,8 +412,6 @@ object ResetExopackColorPacket : CustomPacketPayload { "reset_exopack_color" ) ) - val CODEC: StreamCodec = - StreamCodec.ofMember({ _, _ -> }, { ResetExopackColorPacket }) } class ExopackSmokePacket(val player: UUID) : CustomPacketPayload { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/NetworkPackets.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/NetworkPackets.kt index b97728212..07d715fc8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/NetworkPackets.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/NetworkPackets.kt @@ -44,15 +44,15 @@ internal fun registerNetworkPackets(event: RegisterPayloadHandlersEvent) { .playToClient(ExopackSlotPacket.TYPE, ExopackSlotPacket.CODEC, ExopackSlotPacket::play) .playToClient(ExopackMenuInitPacket.TYPE, ExopackMenuInitPacket.CODEC, ExopackMenuInitPacket::play) .playToClient(ExopackSmokePacket.TYPE, ExopackSmokePacket.CODEC, ExopackSmokePacket::play) - .playToServer(ExopackMenuOpen.TYPE, ExopackMenuOpen.CODEC, ExopackMenuOpen::play) + .playToServer(ExopackMenuOpen.TYPE, ExopackMenuOpen, ExopackMenuOpen::play) .playToServer(PickItemFromInventoryPacket.TYPE, PickItemFromInventoryPacket.CODEC, PickItemFromInventoryPacket::play) - .playToServer(DisplayExopackPacket.TYPE, DisplayExopackPacket.CODEC, DisplayExopackPacket::play) - .playToServer(HideExopackPacket.TYPE, HideExopackPacket.CODEC, HideExopackPacket::play) - .playToServer(EnableExopackGlowPacket.TYPE, EnableExopackGlowPacket.CODEC, EnableExopackGlowPacket::play) - .playToServer(DisableExopackGlowPacket.TYPE, DisableExopackGlowPacket.CODEC, DisableExopackGlowPacket::play) - .playToServer(ResetExopackColorPacket.TYPE, ResetExopackColorPacket.CODEC, ResetExopackColorPacket::play) + .playToServer(DisplayExopackPacket.TYPE, DisplayExopackPacket, DisplayExopackPacket::play) + .playToServer(HideExopackPacket.TYPE, HideExopackPacket, HideExopackPacket::play) + .playToServer(EnableExopackGlowPacket.TYPE, EnableExopackGlowPacket, EnableExopackGlowPacket::play) + .playToServer(DisableExopackGlowPacket.TYPE, DisableExopackGlowPacket, DisableExopackGlowPacket::play) + .playToServer(ResetExopackColorPacket.TYPE, ResetExopackColorPacket, ResetExopackColorPacket::play) .playToServer(SetExopackColorPacket.TYPE, SetExopackColorPacket.CODEC, SetExopackColorPacket::play) // otm player general From 9b384f22133c5d01e3e4a7ba78fa58fafe2bd09d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 07:18:42 +0700 Subject: [PATCH 30/46] Implement sizeToContents() for GridPanel --- .../client/screen/panels/util/GridPanel.kt | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) 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 55a550420..9d17db40e 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 @@ -7,6 +7,7 @@ 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.maybe +import kotlin.math.max open class GridPanel( screen: S, @@ -36,6 +37,37 @@ open class GridPanel( invalidateLayout() } + override fun sizeToContents() { + if (visibleChildren.isEmpty()) { + // nothing to size against + return + } + + visibleChildren.forEach { it.sizeToContents() } + + var width = 0f + var height = 0f + + val children = visibleChildren.iterator().filter { it.dock == Dock.NONE } + + for (row in 0 until rows) { + var maxHeight = 0f + var rowWidth = 0f + + for (column in 0 until columns) { + val nextChild = children.maybe() ?: break + rowWidth += nextChild.width + nextChild.dockMargin.horizontal + maxHeight = max(maxHeight, nextChild.height + nextChild.dockMargin.vertical) + } + + height += maxHeight + width = max(width, rowWidth) + } + + this.width = width + this.height = height + } + override fun performLayout() { super.performLayout() var children = visibleChildren.iterator().filter { it.dock == Dock.NONE } From a48aaf52ae4fcd3e398a2410770007ee67e23a95 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 07:19:03 +0700 Subject: [PATCH 31/46] Add DockProperty#all variant --- .../dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt | 4 ++++ 1 file changed, 4 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 bd1493163..eb2c0aa02 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 @@ -82,6 +82,10 @@ data class DockProperty(val left: Float = 0f, val top: Float = 0f, val right: Fl companion object { val EMPTY = DockProperty() + + fun all(value: Float): DockProperty { + return DockProperty(value, value, value, value) + } } } From e6c970865258d18fd575ebf6b38081bfc8e56113 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 08:07:43 +0700 Subject: [PATCH 32/46] Add layout modes to grid panel --- .../client/screen/panels/util/GridPanel.kt | 82 ++++++++++++++++--- 1 file changed, 70 insertions(+), 12 deletions(-) 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 9d17db40e..4e7dd5800 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 @@ -21,22 +21,80 @@ open class GridPanel( ) : EditablePanel(screen, parent, x, y, width, height) { var columns: Int = columns set(value) { - field = value - invalidateLayout() + if (field != value) { + field = value + invalidateLayout() + } } var rows: Int = rows set(value) { - field = value - invalidateLayout() + if (field != value) { + field = value + invalidateLayout() + } } var gravity: RenderGravity = RenderGravity.CENTER_CENTER set(value) { - field = value - invalidateLayout() + if (field != value) { + field = value + invalidateLayout() + } } + var layout: Layout = Layout.TOP_LEFT + set(value) { + if (field != value) { + field = value + invalidateLayout() + } + } + + enum class Layout { + TOP_LEFT { + override fun rows(last: Int): IntIterator { + return (0 until last).iterator() + } + + override fun columns(last: Int): IntIterator { + return (0 until last).iterator() + } + }, + + TOP_RIGHT { + override fun rows(last: Int): IntIterator { + return (0 until last).iterator() + } + + override fun columns(last: Int): IntIterator { + return (last - 1 downTo 1).iterator() + } + }, + BOTTOM_LEFT { + override fun rows(last: Int): IntIterator { + return (last - 1 downTo 1).iterator() + } + + override fun columns(last: Int): IntIterator { + return (0 until last).iterator() + } + }, + + BOTTOM_RIGHT { + override fun rows(last: Int): IntIterator { + return (last - 1 downTo 1).iterator() + } + + override fun columns(last: Int): IntIterator { + return (last - 1 downTo 1).iterator() + } + }; + + abstract fun rows(last: Int): IntIterator + abstract fun columns(last: Int): IntIterator + } + override fun sizeToContents() { if (visibleChildren.isEmpty()) { // nothing to size against @@ -50,11 +108,11 @@ open class GridPanel( val children = visibleChildren.iterator().filter { it.dock == Dock.NONE } - for (row in 0 until rows) { + for (row in layout.rows(rows)) { var maxHeight = 0f var rowWidth = 0f - for (column in 0 until columns) { + for (column in layout.columns(columns)) { val nextChild = children.maybe() ?: break rowWidth += nextChild.width + nextChild.dockMargin.horizontal maxHeight = max(maxHeight, nextChild.height + nextChild.dockMargin.vertical) @@ -75,11 +133,11 @@ open class GridPanel( var totalWidth = 0f var totalHeight = 0f - for (row in 0 until rows) { + for (row in layout.rows(rows)) { var maxHeight = 0f var width = 0f - for (column in 0 until columns) { + for (column in layout.columns(columns)) { val child = children.maybe() ?: break width += child.dockedWidth maxHeight = maxHeight.coerceAtLeast(child.dockedHeight) @@ -96,11 +154,11 @@ open class GridPanel( totalWidth = 0f totalHeight = 0f - for (row in 0 until rows) { + for (row in layout.rows(rows)) { var maxHeight = 0f var width = 0f - for (column in 0 until columns) { + for (column in layout.columns(columns)) { val child = children.maybe() ?: break child.x = alignX + width child.y = alignY + totalHeight From c343de60314ed00d1924075654ac28606c0c9f3e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 10:45:07 +0700 Subject: [PATCH 33/46] Parenting callbacks in panels --- .../mc/otm/client/screen/panels/EditablePanel.kt | 12 ++++++++++++ 1 file changed, 12 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 eb2c0aa02..530c92222 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 @@ -847,6 +847,12 @@ open class EditablePanel( childrenSortingInvalidated = true } + protected open fun onChildrenAdded(child: EditablePanel<*>) {} + protected open fun onChildrenRemoved(child: EditablePanel<*>) {} + + protected open fun onParented(parent: EditablePanel<*>) {} + protected open fun onUnParented(parent: EditablePanel<*>) {} + private fun onParent(child: EditablePanel<*>) { if (childrenInternal.contains(child)) throw IllegalStateException("Already containing $child") childrenInternal.add(child) @@ -864,11 +870,15 @@ open class EditablePanel( else updateVisibility = true } + + onChildrenAdded(child) + child.onParented(this) } private fun onUnParent(child: EditablePanel<*>) { val indexOf = childrenInternal.indexOf(child) if (indexOf == -1) throw IllegalStateException("Already not containing $child") + child.onUnParented(this) childrenInternal.removeAt(indexOf) invalidateChildrenSorting() @@ -880,6 +890,8 @@ open class EditablePanel( if (child.isVisible() != isVisible()) { updateVisible() } + + onChildrenRemoved(child) } private fun sortChildren() { From 27834cc5951f5133fe51705aeeef1a255bd7ad4e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 12:23:08 +0700 Subject: [PATCH 34/46] Fix wrong layout final iteration value --- .../mc/otm/client/screen/panels/util/GridPanel.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 4e7dd5800..3b655f3de 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 @@ -68,12 +68,12 @@ open class GridPanel( } override fun columns(last: Int): IntIterator { - return (last - 1 downTo 1).iterator() + return (last - 1 downTo 0).iterator() } }, BOTTOM_LEFT { override fun rows(last: Int): IntIterator { - return (last - 1 downTo 1).iterator() + return (last - 1 downTo 0).iterator() } override fun columns(last: Int): IntIterator { @@ -83,11 +83,11 @@ open class GridPanel( BOTTOM_RIGHT { override fun rows(last: Int): IntIterator { - return (last - 1 downTo 1).iterator() + return (last - 1 downTo 0).iterator() } override fun columns(last: Int): IntIterator { - return (last - 1 downTo 1).iterator() + return (last - 1 downTo 0).iterator() } }; From 269227f6cf7ed3f9a0c0a879010bc42bb89d1c00 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 12:58:13 +0700 Subject: [PATCH 35/46] Add helper methods for fast DockProperty creation --- .../otm/client/screen/panels/EditablePanel.kt | 45 +++++++++++++++++++ 1 file changed, 45 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 530c92222..501315db1 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 @@ -83,9 +83,54 @@ data class DockProperty(val left: Float = 0f, val top: Float = 0f, val right: Fl companion object { val EMPTY = DockProperty() + @JvmStatic fun all(value: Float): DockProperty { return DockProperty(value, value, value, value) } + + @JvmStatic + @JvmOverloads + fun topLeft(top: Float, left: Float = top): DockProperty { + return DockProperty(left = left, top = top) + } + + @JvmStatic + fun left(value: Float): DockProperty { + return DockProperty(left = value) + } + + @JvmStatic + @JvmOverloads + fun topRight(top: Float, right: Float = top): DockProperty { + return DockProperty(right = right, top = top) + } + + @JvmStatic + fun right(value: Float): DockProperty { + return DockProperty(right = value) + } + + @JvmStatic + fun top(value: Float): DockProperty { + return DockProperty(top = value) + } + + @JvmStatic + @JvmOverloads + fun bottomLeft(bottom: Float, left: Float = bottom): DockProperty { + return DockProperty(left = left, bottom = bottom) + } + + @JvmStatic + @JvmOverloads + fun bottomRight(bottom: Float, right: Float = bottom): DockProperty { + return DockProperty(right = right, bottom = bottom) + } + + @JvmStatic + fun bottom(value: Float): DockProperty { + return DockProperty(bottom = value) + } } } From 9b27ed7fb6a156f32967000c38efea881ea75759 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 13:33:53 +0700 Subject: [PATCH 36/46] Add netFloat and nextDouble helper methods to RandomSource --- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 18 ++++++++++++++++++ 1 file changed, 18 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 6203217b1..47b8a1c39 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -662,3 +662,21 @@ fun RandomSource.nextNormalDoubles(stddev: Double, mean: Double): DoublePair { fun RandomSource.nextNormalDouble(stddev: Double, mean: Double): Double { return nextGaussian() * stddev + mean } + +fun RandomSource.nextFloat(min: Float, max: Float): Float { + if (this is RandomGenerator) + return nextFloat(min, max) + + require(max >= min) { "Min is bigger than max: $min vs $max" } + if (min == max) return min + return min + nextFloat() * (max - min) +} + +fun RandomSource.nextDouble(min: Double, max: Double): Double { + if (this is RandomGenerator) + return nextDouble(min, max) + + require(max >= min) { "Min is bigger than max: $min vs $max" } + if (min == max) return min + return min + nextDouble() * (max - min) +} From b921658eb2f7118b59c0f292766b17f5b5ee6ee3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 13:34:53 +0700 Subject: [PATCH 37/46] Remove `randomGenerator` from editable panel --- .../client/screen/panels/DecimalHistoryChartPanel.kt | 2 +- .../mc/otm/client/screen/panels/EditablePanel.kt | 4 ---- .../otm/client/screen/tech/AndroidStationScreen.kt | 12 +++++++----- .../ru/dbotthepony/mc/otm/core/math/Clustering.kt | 5 +++-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DecimalHistoryChartPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DecimalHistoryChartPanel.kt index 1b262ce32..dfc9287ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DecimalHistoryChartPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DecimalHistoryChartPanel.kt @@ -52,7 +52,7 @@ open class DecimalHistoryChartPanel>( map[1f] = formatText(maximum) - for (cluster in chart.asIterable().clusterize(randomGenerator)) { + for (cluster in chart.asIterable().clusterize(random)) { val perc = (cluster.center / maximum).toFloat() if (map.keys.none { (it - perc).absoluteValue < 0.08f }) { 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 501315db1..f828af807 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 @@ -232,10 +232,6 @@ open class EditablePanel( } } - val randomGenerator: RandomGenerator by lazy { - RandomSource2Generator(random) - } - /** * Bigger values means lesser priority while docking, rendering and processing inputs. */ 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 f6edd683a..0b52df472 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 @@ -7,6 +7,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import net.minecraft.ChatFormatting import net.minecraft.client.Minecraft import net.minecraft.network.chat.Component +import net.minecraft.util.RandomSource import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack import net.neoforged.neoforge.network.PacketDistributor @@ -34,6 +35,7 @@ import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.kommons.math.RGBAColor import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.screen.panels.button.BooleanButtonPanel +import ru.dbotthepony.mc.otm.core.nextFloat import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu import ru.dbotthepony.mc.otm.network.AndroidResearchRequestPacket import java.util.* @@ -443,8 +445,8 @@ private class AndroidResearchButton( } private enum class PreviewScrollers( - val init: (EditablePanel<*>, RandomGenerator) -> Unit, - val scroll: (EditablePanel<*>, RandomGenerator) -> Boolean + val init: (EditablePanel<*>, RandomSource) -> Unit, + val scroll: (EditablePanel<*>, RandomSource) -> Boolean ) { LEFT_TO_RIGHT( init = { it, random -> @@ -540,14 +542,14 @@ class AndroidStationScreen(p_97741_: AndroidStationMenu, p_97742_: Inventory, p_ if (isPreview && !layoutInvalidated) { if (firstTick) { - scroller.init.invoke(this, randomGenerator) + scroller.init.invoke(this, random) } - val status = scroller.scroll.invoke(this, randomGenerator) + val status = scroller.scroll.invoke(this, random) if (!status) { scroller = PreviewScrollers.entries.let { it[random.nextInt(it.size)] } - scroller.init.invoke(this, randomGenerator) + scroller.init.invoke(this, random) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Clustering.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Clustering.kt index a13d846c0..267d40356 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Clustering.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Clustering.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.core.math import it.unimi.dsi.fastutil.objects.ObjectArrayList +import net.minecraft.util.RandomSource import ru.dbotthepony.mc.otm.core.random import java.util.random.RandomGenerator import kotlin.math.min @@ -88,7 +89,7 @@ private class MutableCluster>(var center: V) { } private fun > Iterable.clusterize( - random: RandomGenerator, + random: RandomSource, initialClusters: Int = 1, zeroBound: Boolean = false, identity: V, @@ -202,7 +203,7 @@ private fun > Iterable.clusterize( // TODO: could use some tweaking private val DECIMAL_ERROR_TOLERANCE = Decimal("0.02") -fun Iterable.clusterize(random: RandomGenerator, clusters: Int? = null, zeroBound: Boolean = false): List> { +fun Iterable.clusterize(random: RandomSource, clusters: Int? = null, zeroBound: Boolean = false): List> { return clusterize(random, clusters ?: 1, zeroBound, Decimal.ZERO, Decimal::plus, Decimal::minus, Decimal::div, Decimal::absoluteValue) { min, max, error -> if (clusters != null) false From f9821aa5520407d11390d58a18dc5bad9d904a56 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 13:36:46 +0700 Subject: [PATCH 38/46] Use GJRAND64 in menus --- .../dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt | 5 +++-- .../mc/otm/client/screen/tech/AndroidStationScreen.kt | 4 ++-- src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 3 ++- 3 files changed, 7 insertions(+), 5 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 f828af807..1b3c0da7f 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,6 +29,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.input.QueryUserPanel import ru.dbotthepony.mc.otm.core.RandomSource2Generator import ru.dbotthepony.mc.otm.core.collect.concatIterators import ru.dbotthepony.mc.otm.core.collect.flatMap +import ru.dbotthepony.mc.otm.core.util.GJRAND64RandomSource import java.util.* import java.util.concurrent.CopyOnWriteArrayList import java.util.function.Predicate @@ -224,11 +225,11 @@ open class EditablePanel( } } - val random: RandomSource by lazy { + val random: GJRAND64RandomSource by lazy { if (screen is MatteryScreen<*>) { screen.menu.random } else { - RandomSource.create() + GJRAND64RandomSource() } } 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 0b52df472..09ef63314 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 @@ -445,8 +445,8 @@ private class AndroidResearchButton( } private enum class PreviewScrollers( - val init: (EditablePanel<*>, RandomSource) -> Unit, - val scroll: (EditablePanel<*>, RandomSource) -> Boolean + val init: (EditablePanel<*>, RandomGenerator) -> Unit, + val scroll: (EditablePanel<*>, RandomGenerator) -> Boolean ) { LEFT_TO_RIGHT( init = { it, random -> 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 8a3711faa..3568f9ecf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -44,6 +44,7 @@ import ru.dbotthepony.mc.otm.container.sortWithIndices import ru.dbotthepony.mc.otm.core.ResourceLocation import ru.dbotthepony.mc.otm.core.collect.ConditionalSet import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.util.GJRAND64RandomSource import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.network.MatteryStreamCodec @@ -81,7 +82,7 @@ abstract class MatteryMenu( val mSynchronizer = SynchableGroup() val synchronizerRemote = mSynchronizer.Remote() val player: Player get() = inventory.player - val random: RandomSource = RandomSource.create() + val random = GJRAND64RandomSource() private val _playerInventorySlots = ArrayList() private val _playerHotbarSlots = ArrayList() From 3e92c5272dd85f0826bfe29a90a1f900beb51316 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 13:52:00 +0700 Subject: [PATCH 39/46] Move panels additional types to separate file --- .../otm/client/screen/panels/EditablePanel.kt | 115 ------------------ .../mc/otm/client/screen/panels/Types.kt | 115 ++++++++++++++++++ 2 files changed, 115 insertions(+), 115 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Types.kt 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 1b3c0da7f..e2be32ce9 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 @@ -11,9 +11,7 @@ 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 -import net.minecraft.util.RandomSource import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.SystemTime import ru.dbotthepony.mc.otm.client.CursorType @@ -26,129 +24,16 @@ 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.RandomSource2Generator import ru.dbotthepony.mc.otm.core.collect.concatIterators import ru.dbotthepony.mc.otm.core.collect.flatMap import ru.dbotthepony.mc.otm.core.util.GJRAND64RandomSource import java.util.* import java.util.concurrent.CopyOnWriteArrayList import java.util.function.Predicate -import java.util.random.RandomGenerator import kotlin.collections.ArrayList import kotlin.math.max import kotlin.math.roundToInt -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 - - operator fun plus(other: DockProperty): DockProperty { - return DockProperty( - left + other.left, - top + other.top, - right + other.right, - bottom + other.bottom - ) - } - - operator fun minus(other: DockProperty): DockProperty { - return DockProperty( - left - other.left, - top - other.top, - right - other.right, - bottom - other.bottom - ) - } - - operator fun plus(other: Float): DockProperty { - return DockProperty( - left + other, - top + other, - right + other, - bottom + other - ) - } - - operator fun minus(other: Float): DockProperty { - return DockProperty( - left - other, - top - other, - right - other, - bottom - other - ) - } - - companion object { - val EMPTY = DockProperty() - - @JvmStatic - fun all(value: Float): DockProperty { - return DockProperty(value, value, value, value) - } - - @JvmStatic - @JvmOverloads - fun topLeft(top: Float, left: Float = top): DockProperty { - return DockProperty(left = left, top = top) - } - - @JvmStatic - fun left(value: Float): DockProperty { - return DockProperty(left = value) - } - - @JvmStatic - @JvmOverloads - fun topRight(top: Float, right: Float = top): DockProperty { - return DockProperty(right = right, top = top) - } - - @JvmStatic - fun right(value: Float): DockProperty { - return DockProperty(right = value) - } - - @JvmStatic - fun top(value: Float): DockProperty { - return DockProperty(top = value) - } - - @JvmStatic - @JvmOverloads - fun bottomLeft(bottom: Float, left: Float = bottom): DockProperty { - return DockProperty(left = left, bottom = bottom) - } - - @JvmStatic - @JvmOverloads - fun bottomRight(bottom: Float, right: Float = bottom): DockProperty { - return DockProperty(right = right, bottom = bottom) - } - - @JvmStatic - fun bottom(value: Float): DockProperty { - return DockProperty(bottom = value) - } - } -} - -enum class Dock { - NONE, LEFT, RIGHT, TOP, BOTTOM, FILL -} - -enum class DockResizeMode(val changeWidth: Boolean, val changeHeight: Boolean) { - ALL(true, true), NONE(false, false), WIDTH(true, false), HEIGHT(false, true) -} - -data class Rect2f(val x: Float, val y: Float, val width: Float, val height: Float) { - fun toIntRect(): Rect2i { - return Rect2i(x.roundToInt(), y.roundToInt(), width.roundToInt(), height.roundToInt()) - } -} - open class EditablePanel( val screen: S, parent: EditablePanel<*>?, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Types.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Types.kt new file mode 100644 index 000000000..7d498d8f6 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Types.kt @@ -0,0 +1,115 @@ +package ru.dbotthepony.mc.otm.client.screen.panels + +import net.minecraft.client.renderer.Rect2i +import kotlin.math.roundToInt + +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 + + operator fun plus(other: DockProperty): DockProperty { + return DockProperty( + left + other.left, + top + other.top, + right + other.right, + bottom + other.bottom + ) + } + + operator fun minus(other: DockProperty): DockProperty { + return DockProperty( + left - other.left, + top - other.top, + right - other.right, + bottom - other.bottom + ) + } + + operator fun plus(other: Float): DockProperty { + return DockProperty( + left + other, + top + other, + right + other, + bottom + other + ) + } + + operator fun minus(other: Float): DockProperty { + return DockProperty( + left - other, + top - other, + right - other, + bottom - other + ) + } + + companion object { + val EMPTY = DockProperty() + + @JvmStatic + fun all(value: Float): DockProperty { + return DockProperty(value, value, value, value) + } + + @JvmStatic + @JvmOverloads + fun topLeft(top: Float, left: Float = top): DockProperty { + return DockProperty(left = left, top = top) + } + + @JvmStatic + fun left(value: Float): DockProperty { + return DockProperty(left = value) + } + + @JvmStatic + @JvmOverloads + fun topRight(top: Float, right: Float = top): DockProperty { + return DockProperty(right = right, top = top) + } + + @JvmStatic + fun right(value: Float): DockProperty { + return DockProperty(right = value) + } + + @JvmStatic + fun top(value: Float): DockProperty { + return DockProperty(top = value) + } + + @JvmStatic + @JvmOverloads + fun bottomLeft(bottom: Float, left: Float = bottom): DockProperty { + return DockProperty(left = left, bottom = bottom) + } + + @JvmStatic + @JvmOverloads + fun bottomRight(bottom: Float, right: Float = bottom): DockProperty { + return DockProperty(right = right, bottom = bottom) + } + + @JvmStatic + fun bottom(value: Float): DockProperty { + return DockProperty(bottom = value) + } + } +} + +enum class Dock { + NONE, LEFT, RIGHT, TOP, BOTTOM, FILL +} + +enum class DockResizeMode(val changeWidth: Boolean, val changeHeight: Boolean) { + ALL(true, true), NONE(false, false), WIDTH(true, false), HEIGHT(false, true) +} + +data class Rect2f(val x: Float, val y: Float, val width: Float, val height: Float) { + fun toIntRect(): Rect2i { + return Rect2i(x.roundToInt(), y.roundToInt(), width.roundToInt(), height.roundToInt()) + } +} From 57c6bbb795d030fd0840772ff8ff1be9c752f688 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 14:00:19 +0700 Subject: [PATCH 40/46] Update cases where wrong random being used --- .../client/render/blockentity/EnergyCounterRenderer.kt | 3 ++- .../kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) 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 2c1b70a67..741f3f925 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 @@ -20,12 +20,13 @@ import ru.dbotthepony.mc.otm.core.math.asAngle import ru.dbotthepony.mc.otm.core.math.clusterize import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.math.times +import ru.dbotthepony.mc.otm.core.util.GJRAND64RandomSource import java.util.Random import kotlin.math.PI import kotlin.math.absoluteValue class EnergyCounterRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { - private val random = Random() + private val random = GJRAND64RandomSource() override fun render( tile: EnergyCounterBlockEntity, 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 961540d14..411b081c6 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 @@ -9,6 +9,7 @@ import net.minecraft.network.chat.FormattedText import net.minecraft.network.chat.MutableComponent import net.minecraft.world.inventory.tooltip.TooltipComponent import ru.dbotthepony.kommons.math.RGBAColor +import ru.dbotthepony.mc.otm.THREAD_LOCAL_RANDOM import ru.dbotthepony.mc.otm.client.render.ChartLevelLabels import ru.dbotthepony.mc.otm.client.render.ChartTooltipElement import ru.dbotthepony.mc.otm.config.ClientConfig @@ -453,10 +454,8 @@ private fun formatHistoryChart( labelNames[0f] = (-maxTransferred).formatSiComponent(suffix, decimals, formatAsReadable = verbose, bias = bias) labelNames[1f] = maxReceived.formatSiComponent(suffix, decimals, formatAsReadable = verbose, bias = bias) - val rand = java.util.Random() - if (maxTransferred.isNotZero && transferredMult > 0.2f) { - for (cluster in widget.transferred.clusterize(rand, zeroBound = true)) { + for (cluster in widget.transferred.clusterize(THREAD_LOCAL_RANDOM, zeroBound = true)) { val perc = (cluster.center / maxTransferred).toFloat() * transferredMult if (labelNames.keys.none { (it - perc).absoluteValue < 0.08f }) @@ -465,7 +464,7 @@ private fun formatHistoryChart( } if (maxReceived.isNotZero && receivedMult > 0.2f) { - for (cluster in widget.received.clusterize(rand, zeroBound = true)) { + for (cluster in widget.received.clusterize(THREAD_LOCAL_RANDOM, zeroBound = true)) { val perc = zero + (cluster.center / maxReceived).toFloat() * receivedMult if (labelNames.keys.none { (it - perc).absoluteValue < 0.08f }) @@ -473,7 +472,7 @@ private fun formatHistoryChart( } } - val clusters = diff.asIterable().clusterize(rand, zeroBound = true) + val clusters = diff.asIterable().clusterize(THREAD_LOCAL_RANDOM, zeroBound = true) for (cluster in clusters) { val perc: Float From 7c028b1fa637486c86ab875d13f96ae4050b108c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 15:11:09 +0700 Subject: [PATCH 41/46] Im with stupid --- .../client/screen/panels/util/GridPanel.kt | 79 ++++++++++--------- 1 file changed, 43 insertions(+), 36 deletions(-) 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 3b655f3de..008634fac 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 @@ -53,46 +53,54 @@ open class GridPanel( enum class Layout { TOP_LEFT { - override fun rows(last: Int): IntIterator { - return (0 until last).iterator() - } - - override fun columns(last: Int): IntIterator { - return (0 until last).iterator() + override fun get( + list: List>, + row: Int, + column: Int, + rows: Int, + columns: Int + ): EditablePanel<*>? { + return list.getOrNull(column + row * columns) } }, TOP_RIGHT { - override fun rows(last: Int): IntIterator { - return (0 until last).iterator() - } - - override fun columns(last: Int): IntIterator { - return (last - 1 downTo 0).iterator() + override fun get( + list: List>, + row: Int, + column: Int, + rows: Int, + columns: Int + ): EditablePanel<*>? { + return list.getOrNull((columns - column - 1) + row * columns) } }, - BOTTOM_LEFT { - override fun rows(last: Int): IntIterator { - return (last - 1 downTo 0).iterator() - } - override fun columns(last: Int): IntIterator { - return (0 until last).iterator() + BOTTOM_LEFT { + override fun get( + list: List>, + row: Int, + column: Int, + rows: Int, + columns: Int + ): EditablePanel<*>? { + return list.getOrNull(column + (rows - row - 1) * columns) } }, BOTTOM_RIGHT { - override fun rows(last: Int): IntIterator { - return (last - 1 downTo 0).iterator() - } - - override fun columns(last: Int): IntIterator { - return (last - 1 downTo 0).iterator() + override fun get( + list: List>, + row: Int, + column: Int, + rows: Int, + columns: Int + ): EditablePanel<*>? { + return list.getOrNull((columns - column - 1) + (rows - row - 1) * columns) } }; - abstract fun rows(last: Int): IntIterator - abstract fun columns(last: Int): IntIterator + abstract fun get(list: List>, row: Int, column: Int, rows: Int, columns: Int): EditablePanel<*>? } override fun sizeToContents() { @@ -108,11 +116,11 @@ open class GridPanel( val children = visibleChildren.iterator().filter { it.dock == Dock.NONE } - for (row in layout.rows(rows)) { + for (row in 0 until rows) { var maxHeight = 0f var rowWidth = 0f - for (column in layout.columns(columns)) { + for (column in 0 until columns) { val nextChild = children.maybe() ?: break rowWidth += nextChild.width + nextChild.dockMargin.horizontal maxHeight = max(maxHeight, nextChild.height + nextChild.dockMargin.vertical) @@ -128,17 +136,17 @@ open class GridPanel( override fun performLayout() { super.performLayout() - var children = visibleChildren.iterator().filter { it.dock == Dock.NONE } + val children = visibleChildren.stream().filter { it.dock == Dock.NONE }.toList() var totalWidth = 0f var totalHeight = 0f - for (row in layout.rows(rows)) { + for (row in 0 until rows) { var maxHeight = 0f var width = 0f - for (column in layout.columns(columns)) { - val child = children.maybe() ?: break + for (column in 0 until columns) { + val child = layout.get(children, row, column, rows, columns) ?: continue width += child.dockedWidth maxHeight = maxHeight.coerceAtLeast(child.dockedHeight) } @@ -149,17 +157,16 @@ open class GridPanel( 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 layout.rows(rows)) { + for (row in 0 until rows) { var maxHeight = 0f var width = 0f - for (column in layout.columns(columns)) { - val child = children.maybe() ?: break + for (column in 0 until columns) { + val child = layout.get(children, row, column, rows, columns) ?: continue child.x = alignX + width child.y = alignY + totalHeight width += child.dockedWidth From a2d9f43a2e8f5a030264425b0062ce56361cb322 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 18:17:50 +0700 Subject: [PATCH 42/46] Fix grid panel layouts, introduce column major order --- .../client/screen/panels/util/GridPanel.kt | 58 ++++++++++++++----- 1 file changed, 44 insertions(+), 14 deletions(-) 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 008634fac..28b32a5fd 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 @@ -7,6 +7,8 @@ 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.maybe +import java.util.stream.IntStream +import java.util.stream.Stream import kotlin.math.max open class GridPanel( @@ -51,6 +53,14 @@ open class GridPanel( } } + var columnMajorOrder = false + set(value) { + if (field != value) { + field = value + invalidateLayout() + } + } + enum class Layout { TOP_LEFT { override fun get( @@ -58,9 +68,14 @@ open class GridPanel( row: Int, column: Int, rows: Int, - columns: Int + columns: Int, + columnMajorOrder: Boolean ): EditablePanel<*>? { - return list.getOrNull(column + row * columns) + if (columnMajorOrder) { + return list.getOrNull(row + column * rows) + } else { + return list.getOrNull(column + row * columns) + } } }, @@ -70,9 +85,14 @@ open class GridPanel( row: Int, column: Int, rows: Int, - columns: Int + columns: Int, + columnMajorOrder: Boolean ): EditablePanel<*>? { - return list.getOrNull((columns - column - 1) + row * columns) + if (columnMajorOrder) { + return list.getOrNull(row + (columns - column - 1) * rows) + } else { + return list.getOrNull((columns - column - 1) + row * columns) + } } }, @@ -82,9 +102,14 @@ open class GridPanel( row: Int, column: Int, rows: Int, - columns: Int + columns: Int, + columnMajorOrder: Boolean ): EditablePanel<*>? { - return list.getOrNull(column + (rows - row - 1) * columns) + if (columnMajorOrder) { + return list.getOrNull((rows - row - 1) + column * rows) + } else { + return list.getOrNull(column + (rows - row - 1) * columns) + } } }, @@ -94,13 +119,18 @@ open class GridPanel( row: Int, column: Int, rows: Int, - columns: Int + columns: Int, + columnMajorOrder: Boolean ): EditablePanel<*>? { - return list.getOrNull((columns - column - 1) + (rows - row - 1) * columns) + if (columnMajorOrder) { + return list.getOrNull((rows - row - 1) + (columns - column - 1) * rows) + } else { + return list.getOrNull((columns - column - 1) + (rows - row - 1) * columns) + } } }; - abstract fun get(list: List>, row: Int, column: Int, rows: Int, columns: Int): EditablePanel<*>? + abstract fun get(list: List>, row: Int, column: Int, rows: Int, columns: Int, columnMajorOrder: Boolean): EditablePanel<*>? } override fun sizeToContents() { @@ -114,14 +144,14 @@ open class GridPanel( var width = 0f var height = 0f - val children = visibleChildren.iterator().filter { it.dock == Dock.NONE } + val children = visibleChildren.filter { it.dock == Dock.NONE } for (row in 0 until rows) { var maxHeight = 0f var rowWidth = 0f for (column in 0 until columns) { - val nextChild = children.maybe() ?: break + val nextChild = layout.get(children, row, column, rows, columns, columnMajorOrder) ?: continue rowWidth += nextChild.width + nextChild.dockMargin.horizontal maxHeight = max(maxHeight, nextChild.height + nextChild.dockMargin.vertical) } @@ -136,7 +166,7 @@ open class GridPanel( override fun performLayout() { super.performLayout() - val children = visibleChildren.stream().filter { it.dock == Dock.NONE }.toList() + val children = visibleChildren.filter { it.dock == Dock.NONE } var totalWidth = 0f var totalHeight = 0f @@ -146,7 +176,7 @@ open class GridPanel( var width = 0f for (column in 0 until columns) { - val child = layout.get(children, row, column, rows, columns) ?: continue + val child = layout.get(children, row, column, rows, columns, columnMajorOrder) ?: continue width += child.dockedWidth maxHeight = maxHeight.coerceAtLeast(child.dockedHeight) } @@ -166,7 +196,7 @@ open class GridPanel( var width = 0f for (column in 0 until columns) { - val child = layout.get(children, row, column, rows, columns) ?: continue + val child = layout.get(children, row, column, rows, columns, columnMajorOrder) ?: continue child.x = alignX + width child.y = alignY + totalHeight width += child.dockedWidth From 06f109575d10bc29e6fda32daacbfee550c13b1a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 18:18:07 +0700 Subject: [PATCH 43/46] Fix children not getting re-sorted upon visibility changes --- .../dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt | 3 +++ 1 file changed, 3 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 e2be32ce9..247d22b28 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 @@ -281,11 +281,13 @@ open class EditablePanel( if (visibleChildrenParent?.contains(this) == false) { visibleChildrenParent.add(this) + parent?.invalidateChildrenSorting() parent?.layoutInvalidated = true } } else { if (visibleChildrenParent?.contains(this) == true) { visibleChildrenParent.remove(this) + parent?.invalidateChildrenSorting() parent?.layoutInvalidated = true } } @@ -1451,6 +1453,7 @@ open class EditablePanel( if (old != new) { child.visibilityChanges(new, old) + child.invalidateChildrenSorting() } child.updateVisible() From bfb8f0380a3d020d8a376af060fb20ffcdbb2b82 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 21:10:46 +0700 Subject: [PATCH 44/46] Panel debug rendering --- .../mc/otm/client/render/MGUIGraphics.kt | 69 ++++++++++ .../mc/otm/client/render/RenderHelper.kt | 119 +++++++++++++----- .../mc/otm/client/screen/MatteryScreen.kt | 11 +- .../otm/client/screen/panels/EditablePanel.kt | 16 ++- .../otm/client/screen/panels/Panel2Widget.kt | 10 +- 5 files changed, 189 insertions(+), 36 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 ee79d0a17..c7354cff0 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 @@ -14,6 +14,8 @@ import net.minecraft.world.inventory.tooltip.TooltipComponent import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.kommons.math.RGBAColor +import ru.dbotthepony.mc.otm.client.screen.panels.ScreenPos +import java.util.Arrays import kotlin.math.PI import kotlin.math.roundToInt @@ -45,6 +47,73 @@ class MGUIGraphics(val parent: GuiGraphics) { drawLine(pose.last().pose(), startX, startY, endX, endY, width, z, color) } + fun drawLine( + points: Iterable, + width: Float, + color: RGBAColor = RGBAColor.WHITE + ) { + drawLine(pose.last().pose(), points, width, color) + } + + fun drawLine( + points: Array, + width: Float, + color: RGBAColor = RGBAColor.WHITE + ) { + drawLine(pose.last().pose(), points, width, color) + } + + fun drawLine( + width: Float, + color: RGBAColor, + vararg points: LinePoint, + ) { + drawLine(pose.last().pose(), points, width, color) + } + + fun drawLine( + width: Float, + color: RGBAColor, + points: Iterable, + ) { + drawLine(pose.last().pose(), points, width, color) + } + + fun drawLine( + width: Float, + color: RGBAColor, + z: Float, + points: List, + ) { + require(points.size >= 2) { "Degenerate point list: only ${points.size} defined" } + + val result = ArrayList(points.size) + + for (i in 1 until points.size) { + val (x0, y0) = points[i - 1] + val (x1, y1) = points[i] + + result.add( + LinePoint( + x0, y0, + x1, y1, + z + ) + ) + } + + drawLine(pose.last().pose(), result, width, color) + } + + fun drawLine( + width: Float, + color: RGBAColor, + z: Float, + vararg points: ScreenPos, + ) { + drawLine(width, color, z, Arrays.asList(*points)) + } + fun renderRect( x: Float, y: 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 2d54cc06b..c4d3a331a 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 @@ -294,6 +294,65 @@ fun renderColoredSphere(pose: PoseStack, radius: Float, color: RGBAColor = RGBAC BufferUploader.drawWithShader(builder.buildOrThrow()) } +private fun uploadLineSegment( + builder: BufferBuilder, + matrix: Matrix4f, + startX: Float, + startY: Float, + endX: Float, + endY: Float, + width: Float, + z: Float, + color: RGBAColor = RGBAColor.WHITE +) { + val length = ((startX - endX).pow(2f) + (startY - endY).pow(2f)).pow(0.5f) + var angle = acos((endX - startX) / length) + + if (startY > endY) + angle *= -1f + + val cos = cos(angle) + val sin = sin(angle) + + val y0 = -width + + val y1 = width + + val x2 = length + val y2 = width + + val x3 = length + val y3 = -width + + builder.vertex(matrix, + startX - y0 * sin, + startY + y0 * cos, + z).color(color) + + builder.vertex(matrix, + startX - y1 * sin, + startY + y1 * cos, + z).color(color) + + builder.vertex(matrix, + startX + x2 * cos - y2 * sin, + startY + x2 * sin + y2 * cos, + z).color(color) + + builder.vertex(matrix, + startX + x3 * cos - y3 * sin, + startY + x3 * sin + y3 * cos, + z).color(color) +} + +data class LinePoint( + val startX: Float, + val startY: Float, + val endX: Float, + val endY: Float, + val z: Float = 0f, +) + fun drawLine( matrix: Matrix4f, startX: Float, @@ -312,46 +371,46 @@ fun drawLine( RenderSystem.depthFunc(GL_ALWAYS) val builder = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR) + uploadLineSegment(builder, matrix, startX, startY, endX, endY, width, z, color) + BufferUploader.drawWithShader(builder.buildOrThrow()) +} - val length = ((startX - endX).pow(2f) + (startY - endY).pow(2f)).pow(0.5f) - val angle = acos((endX - startX) / length) +fun drawLine( + matrix: Matrix4f, + points: Iterable, + width: Float, + color: RGBAColor = RGBAColor.WHITE +) { + val itr = points.iterator() - val cos = cos(angle) - val sin = sin(angle) + if (!itr.hasNext()) { + throw IllegalArgumentException("No line points were provided") + } - val y0 = -width + RenderSystem.setShader(GameRenderer::getPositionColorShader) + RenderSystem.enableBlend() + RenderSystem.defaultBlendFunc() - val y1 = width + if (!is3DContext) + RenderSystem.depthFunc(GL_ALWAYS) - val x2 = length - val y2 = width + val builder = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR) - val x3 = length - val y3 = -width - - builder.vertex(matrix, - startX - y0 * sin, - startY + y0 * cos, - z).color(color) - - builder.vertex(matrix, - startX - y1 * sin, - startY + y1 * cos, - z).color(color) - - builder.vertex(matrix, - startX + x2 * cos - y2 * sin, - startY + x2 * sin + y2 * cos, - z).color(color) - - builder.vertex(matrix, - startX + x3 * cos - y3 * sin, - startY + x3 * sin + y3 * cos, - z).color(color) + for ((startX, startY, endX, endY, z) in itr) + uploadLineSegment(builder, matrix, startX, startY, endX, endY, width, z, color) BufferUploader.drawWithShader(builder.buildOrThrow()) } +fun drawLine( + matrix: Matrix4f, + points: Array, + width: Float, + color: RGBAColor = RGBAColor.WHITE +) { + return drawLine(matrix, points.asIterable(), width, color) +} + data class ScissorRect(val xStart: Int, val yStart: Int, val xEnd: Int, val yEnd: Int, val lock: Boolean = false) { val width: Int get() = (xEnd - xStart).coerceAtLeast(0) 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 23e70a863..fad46c6d4 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,9 +17,11 @@ import net.neoforged.neoforge.common.NeoForge import org.lwjgl.opengl.GL11 import ru.dbotthepony.kommons.util.getValue import ru.dbotthepony.kommons.util.setValue +import ru.dbotthepony.kommons.math.RGBAColor import ru.dbotthepony.mc.otm.player.matteryPlayer import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.moveMousePosScaled +import ru.dbotthepony.mc.otm.client.render.LinePoint import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.translation @@ -55,6 +57,7 @@ import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import java.util.* import java.util.concurrent.CopyOnWriteArrayList +import kotlin.collections.ArrayList import kotlin.collections.List import kotlin.collections.MutableSet import kotlin.collections.isNotEmpty @@ -690,7 +693,13 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit for (panel in panelsReversed) { RenderSystem.depthFunc(GL11.GL_ALWAYS) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - panel.render(wrap, mouseXf, mouseYf, partialTick) + val segments = ArrayList() + + panel.render(wrap, mouseXf, mouseYf, partialTick, segments) + + if (segments.isNotEmpty()) { + wrap.drawLine(0.5f, RGBAColor.GOLD, segments) + } } if (!panelsReversed.any { it.updateCursor0() }) 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 247d22b28..0228f172b 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 @@ -13,11 +13,13 @@ import net.minecraft.client.gui.navigation.ScreenRectangle import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import org.apache.logging.log4j.LogManager +import ru.dbotthepony.kommons.math.RGBAColor import ru.dbotthepony.mc.otm.SystemTime import ru.dbotthepony.mc.otm.client.CursorType 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.LinePoint import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.currentScissorRect import ru.dbotthepony.mc.otm.client.render.popScissorRect @@ -889,12 +891,11 @@ open class EditablePanel( } } - fun render(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + fun render(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float, debugSegments: MutableList) { once = true - if (!isVisible()) { + if (!isVisible()) return - } val poseStack = graphics.pose @@ -942,12 +943,19 @@ open class EditablePanel( child.absoluteX = absoluteX + child.x + xOffset child.absoluteY = absoluteY + child.y + yOffset - child.render(graphics, mouseX, mouseY, partialTick) + child.render(graphics, mouseX, mouseY, partialTick, debugSegments) } if (scissor) { popScissorRect() } + + if (minecraft.entityRenderDispatcher.shouldRenderHitBoxes()) { + debugSegments.add(LinePoint(absoluteX, absoluteY, absoluteX + width, absoluteY)) + debugSegments.add(LinePoint(absoluteX + width, absoluteY, absoluteX + width, absoluteY + height)) + debugSegments.add(LinePoint(absoluteX + width, absoluteY + height, absoluteX, absoluteY + height)) + debugSegments.add(LinePoint(absoluteX, absoluteY + height, absoluteX, absoluteY)) + } } fun updateCursor0(): Boolean { 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 6c06bc038..bd5bdaee8 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,8 @@ 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.kommons.math.RGBAColor +import ru.dbotthepony.mc.otm.client.render.LinePoint import ru.dbotthepony.mc.otm.client.render.MGUIGraphics // before 1.19.3 Renderable was Widget @@ -21,11 +23,17 @@ class Panel2Widget>( val yFloat = mouseY.toFloat() val wrap = MGUIGraphics(graphics) + val segments = ArrayList() panel.tickHovered0(xFloat, yFloat, false) panel.tickHovered1() panel.tickHovered2() - panel.render(wrap, xFloat, yFloat, partialTick) + panel.render(wrap, xFloat, yFloat, partialTick, segments) + + if (segments.isNotEmpty()) { + wrap.drawLine(0.5f, RGBAColor.GOLD, segments) + } + panel.renderTooltips(wrap, xFloat, yFloat, partialTick) } From ab2cc33b7a330f1ec0164748e263e6f9d0822c31 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 21:24:16 +0700 Subject: [PATCH 45/46] "Smart storage exchange icon" --- .../mc/otm/client/render/Widgets18.kt | 1 + .../textures/gui/widgets/storage_controls.png | Bin 1303 -> 1329 bytes .../textures/gui/widgets/storage_controls.xcf | Bin 16168 -> 16856 bytes 3 files changed, 1 insertion(+) 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 21aa5a69c..ec3f41496 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 @@ -30,6 +30,7 @@ object Widgets18 { val RESTOCK_FROM_STORAGE = storageGrid.next() val RESTOCK_WITH_MOVE_TO_STORAGE = storageGrid.next() val RESTOCK_WITH_MOVE_FROM_STORAGE = storageGrid.next() + val SMART_STORAGE_EXCHANGE = storageGrid.next() private val miscGrid = WidgetLocation.WIDGET_18.grid(4, 4) 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 d46201f5e4b8bb78105dec2c9e8c3a39eb5432a1..7c39f8ee48dd4cb598345aed4376cad31105b975 100644 GIT binary patch delta 1139 zcmV-(1dRKa3b6{1J%2zP#a~lJk*b5Wh&W`ZPIgfd$5O>2SSW3URvk<({emV9Ns5c3 z;979-W3lSs;;gHKs~`w|fVc}ziY`*(|B^zB7!Qv7@$TN^?j0aBDoi!IqJXMdMk*c? zv$<8V=M{boV*nw9BxdS~^kN2{JD8OWm3W3Ytf(603t5*H z&Rd+-N{zMd$zK@AYb$B4(;Pz_OGqFI5i)8hqXG*NS~XHkq-a0p;U9JUNpi{LDua<@ z0ad7w96$IU{D1D&EKEK2h+1tNoTK)Y1jYo2^w|A!J00006VoOIv0F$}_DGU`37a|9R)$afR11^*A z0V^aTvq%Fw6&I3;+NC8+Lthyly)3h-0}Gt?cFk%tyWSrI;ZWDSw?BkG96SeqxSUM z%I6Xkn=RG*%$YjW&QPZy)uyKGD~F_1I|<1Wp8RZPf@3Nq#8G5QOb0n&L2yEwabnZ4 z*liBcT7eG&761SM0001>gD*{SXW`z#k3JX;(Ipj*k_w45?_5jH(3ATDDt}$t=v0!Q zO9V$wX{82>p|V@Yc>z@y!#$ChGJo4PsoCILbU0St*Rp}zEe9HMs8yCOTNREP0aAbW zpipIU^o|%?DMGV-9V2SCv`>B7 zRR38^PA&hv_#2jzibk$7Q=@Vtbv?VLNlW}=39&87?)7||>yY%2r+?heOzQoVADp{S zC0y!PbD!@tHKTUq7Avjw3P!lkcN!09F&GK)z56FxO=H*at%SJ_$&q9^-0%133pt<9 zEDe}lPBeR`Jq>@~p3TeCt1-ry&z}!-djC3{9N%K0JH3CIZ}Z=Y(?R9|G@af%3(!$?LZyURB$ zlv89l&zGJ`(-M}debV!Wv@0Q{@`f}W8dFre64JY}(u8P@gQGM^>0Ma?28QLt^2W?x z8R>mUbW`^Zr~p(n002ni4`W`y`4Bw(T9p6*002ovPDHLk FV1jZO7()O6 delta 1112 zcmV-e1gHD43YQ9yJ%3OXg-=tZB9$U`5Ov5E^lTmwqMWPgB9B#trNu!uK^XE!aK z^FDEyl_iDvoOsfp28kcJF1!53x#Y0GGs8wUJx?4a7E4_$cQGp)D)9_)L{T-$7jiBu zoVPfu)jDhU$zK>OXe$}6Q;i{kB_xr82pM%$P=$pk?HVa2(sUm8@Q*nD6uD$_Rlvxx zfErXtjvxFFet*x_EKX0kNx?YK`(oQ4<3L~+Xf5?HilAlT_7J>IO`ldWEbPM#axpQlup|V@Yc>z@y!y}QHGJo4PsoCK7=y0sOuVn+bTMjhjP^&CWwkpgT0aAbW zpip{g z0HgHLNga7k#o^IFT1Sj~DZ+01I(pP>X`dwR{E?%-o?iSgr7Y=b*%8+a0002sAjtX0 zRR38^PA&hv_zX))MI%?4sZqI+x}Htbq$U2bgxEdFZuNYd>yY##Pk*_cnbi9!KR9=v zO1RXo=04wPYDVqIEmm4<6^wA7?=&8;$6zGHx9*>4HH}@vw-V+$B%dV9;eNkIU< zW@*6aa-!Kg?P>V?_H16BUX3xveExix)BD$Sa{L|(-Rb?ye4GDHoF~ zZ>Y2qGKJ~TnDVVFAwv?a@!=?h_dpvP-CIRtbUfU)+gtwkutfKk|Aj_FqoL75x_3YY epb`N9KpKCAH*eLfyuZr;00000MgHQS^ljY*p{W@&!f*wnPa*mP~uq-krsSjFa0@ZeuTtOo;n(u<}C z#R?UvjHmjKiV9LK(^9IbtscB+VHLq3B1jPg4~nP<#jd;GB;c`o*k`_H-gjr0y;~@q zBI9Ss?1j-UBXI$*HOri4D`)k0&YBdb!@*hS=d9-tybt-JA;}pCaW>uOY%cF_xWVVP zBb*zDINRHEe9>`&v$K&iQ7)!{&)o&io@pwB-{)3uszr7F)tEXLP@kw%`Y@x;8xbQ< zr@Z4NMAwQvju~F7+{JBlNR-Jzsz%+L#FG^r7C_SkNizvnO%!Z8jk&5!Nt19k(Z7BH*!O#M6oqPnM0j z@*>DnXyqle@+THucL2cGkJdMg)>mN9W&L%7VYI=lVJ*Sk5PIYnbl1y*eA2M8}>Ap9O59{$17>*oL>570(lpp7iE)|Lr?=m^^ACEeB& z#{NWR0b+TSv9lPBU1y)8lK}A?+ISvq{4{$R^8hGU=}|={k5DSFnKwQNkZ8eZVyj^- zi9MB9e5!QQqT*&NN;QGxGYlm^U^V%RWjdWe(v-yOsFpI5W-O;OmGZ~rJ+`@Pnn30j b7Bh=j%#>Il{hL7V8??RO(Ds>WE>rpkobe4z delta 831 zcmYk2PiPZC6o)f!lhCz`(QQ+bE(sdDCZ>tT#+bxzqm}BR3W^Ad_=n;_4}nyXDkv3H z6j7wjc#tB}gQ8N2!YdU~=uJVT^&l7&!IPItRM3kEb>~e6+{^cv@Auy9oBBoeV07#< zn;yTiaK76^pYNb#%T~$OYm!TcB$rnt+jmQbBs`s0Wf3_gx#F*6SJSWlDT_6;lBp+> z>n0_8*1wg-hLe&TB|L>ave+~y+2?Hv5AWC7c*DER3+@RYij47D-!9OOyXO|WM0Qy7 zvfDV|{|(^h?nx*39}D4gJN&P(qTdJ5he_zymC*0vP9vy+@tlP5K?&nKujna0A85fh zfkOa+3ls?4QGvh=9yUJ$m{k&HO$qbmf1L)yTE{*H!6TFko>i$J$KFs`gD@izjwlh% z;b-e8fHgtFno+`sMxX1aF>ftHD3uASMFfd*gYIvb&Nr*m2$DT%EdM} zbNq`vie-Bcz+OffJ0&vWq3i+t7Jmj1UnG&Rlt^UpQ*r_zIZqr9^zMLnnCX`$~fWysM$&2 UyV4&9r7jYsElQO3SNrS#0AS^*Q2+n{ From 0126d4d9767f5a0fccf339dd1dbc700d5788abf2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 22 Mar 2025 00:30:03 +0700 Subject: [PATCH 46/46] Don't override nextGaussian, because JVM implementation should be generally faster --- .../dbotthepony/mc/otm/core/util/GJRAND64RandomSource.kt | 8 -------- .../mc/otm/core/util/IRandomSourceGenerator.kt | 4 +++- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/GJRAND64RandomSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/GJRAND64RandomSource.kt index c8adbfa13..f26a4aaae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/GJRAND64RandomSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/GJRAND64RandomSource.kt @@ -2,15 +2,12 @@ package ru.dbotthepony.mc.otm.core.util import net.minecraft.util.Mth import net.minecraft.util.RandomSource -import net.minecraft.world.level.levelgen.MarsagliaPolarGaussian import net.minecraft.world.level.levelgen.PositionalRandomFactory import net.minecraft.world.level.levelgen.RandomSupport import ru.dbotthepony.kommons.random.GJRAND64Random import java.lang.StringBuilder class GJRAND64RandomSource : GJRAND64Random, IRandomSourceGenerator { - private val gaussian = MarsagliaPolarGaussian(this) - constructor() : super(RandomSupport.generateUniqueSeed(), RandomSupport.generateUniqueSeed()) constructor(seed: Long) : super(seed) constructor(seed0: Long, seed1: Long) : super(seed0, seed1) @@ -19,10 +16,6 @@ class GJRAND64RandomSource : GJRAND64Random, IRandomSourceGenerator { return nextLong().ushr(32).toInt() } - override fun nextGaussian(): Double { - return gaussian.nextGaussian() - } - override fun fork(): RandomSource { return GJRAND64RandomSource(nextLong(), nextLong()) } @@ -33,7 +26,6 @@ class GJRAND64RandomSource : GJRAND64Random, IRandomSourceGenerator { override fun setSeed(seed: Long) { reinitialize(seed) - gaussian.reset() } class Positional(private val seed0: Long, private val seed1: Long) : PositionalRandomFactory { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IRandomSourceGenerator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IRandomSourceGenerator.kt index 999e39cfd..cd0fa1e47 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IRandomSourceGenerator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IRandomSourceGenerator.kt @@ -26,5 +26,7 @@ interface IRandomSourceGenerator : RandomSource, RandomGenerator { return super.nextDouble() } - override fun nextGaussian(): Double + override fun nextGaussian(): Double { + return super.nextGaussian() + } }