From 7c794126b655f26146a526cdbbd89c3f248444ae Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sun, 21 Jan 2024 11:55:58 +0300 Subject: [PATCH] slurp --- .../mc/otm/datagen/lang/English.kt | 4 +- .../mc/otm/datagen/lang/Russian.kt | 4 +- .../entity/tech/EssenceStorageBlockEntity.kt | 39 +++++++++++++++++++ .../mc/otm/config/MachinesConfig.kt | 14 +++++++ .../resources/META-INF/accesstransformer.cfg | 2 + 5 files changed, 59 insertions(+), 4 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index c86a0526d..2140cb5ed 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -608,8 +608,8 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ESSENCE_CAPSULE, "Essence Capsule") add(MItems.ESSENCE_DRIVE, "Essence Memory Holotape") add(MItems.ESSENCE_SERVO, "Essence Servo") - add(MItems.ESSENCE_SERVO, "desc", "Allows to 'pump' essence involving fleshy humanoids") - add(MItems.ESSENCE_SERVO, "desc2", "Can be used standalone, or as tool inside Essence Servo") + add(MItems.ESSENCE_SERVO, "desc", "Allows to absorb nearby experience orbs directly into essence storage") + add(MItems.ESSENCE_SERVO, "desc2", "Can be used as a tool to pump essence manually") add(MItems.NUTRIENT_PASTE, "Nutrient Paste") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 579fac976..b975b1b16 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -612,8 +612,8 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ESSENCE_CAPSULE, "Капсула эссенции") add(MItems.ESSENCE_DRIVE, "Голодиск воспоминаний андроида") add(MItems.ESSENCE_SERVO, "Помпа эссенции") - add(MItems.ESSENCE_SERVO, "desc", "Позволяет 'перекачивать' эссенцию гуманоидов из плоти") - add(MItems.ESSENCE_SERVO, "desc2", "Может быть использовано напрямую, или как инструмент внутри хранилища эссенции") + add(MItems.ESSENCE_SERVO, "desc", "Позволяет всасывать близлежащие сферы опыта напрямую в хранилище эссенции") + add(MItems.ESSENCE_SERVO, "desc2", "Может использоваться как инструмент для ручной перекачки эссенции") add(MItems.NUTRIENT_PASTE, "Питательная паста") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt index 58a1d287c..09b936abb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt @@ -1,6 +1,10 @@ package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos +import net.minecraft.server.level.ServerLevel +import net.minecraft.sounds.SoundEvents +import net.minecraft.sounds.SoundSource +import net.minecraft.world.entity.ExperienceOrb import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -12,9 +16,13 @@ import net.minecraftforge.fluids.capability.IFluidHandler import ru.dbotthepony.mc.otm.block.entity.ExperienceStorage.Companion.XP_TO_LIQUID_RATIO import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.item.CombinedItemHandler +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid +import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem +import ru.dbotthepony.mc.otm.item.EssenceServoItem import ru.dbotthepony.mc.otm.menu.tech.EssenceStorageMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MFluids @@ -146,6 +154,37 @@ class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma repairStack.damageValue -= repairPoints } } + + val servo = servoContainer[0] + + if (!servo.isEmpty && servo.item is EssenceServoItem && level is ServerLevel) { + val entities = level!!.getEntitiesInEllipsoid( + blockPos.center, + Vector( + MachinesConfig.EssenceStorage.RADIUS_HORIZONTAL, + MachinesConfig.EssenceStorage.RADIUS_VERTICAL, + MachinesConfig.EssenceStorage.RADIUS_HORIZONTAL + ) + ) { it is ExperienceOrb } + + for ((ent, _) in entities) { + ent as ExperienceOrb + + for (i in 1 .. ent.count) { + experienceStored += ent.value + ent.count-- + + level!!.playSound(null, ent.x, ent.y, ent.z, + SoundEvents.EXPERIENCE_ORB_PICKUP, SoundSource.BLOCKS, + 0.1F, 0.5F + level!!.random.nextFloat() * 0.25F + ) + } + + if (ent.count <= 0) { + ent.discard() + } + } + } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index cc3358134..5eff8cfc2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -219,7 +219,21 @@ object MachinesConfig : AbstractConfig("machines") { } } + object EssenceStorage { + init { + builder.push(MNames.ESSENCE_STORAGE) + } + + val RADIUS_HORIZONTAL: Double by builder.defineInRange("RADIUS_HORIZONTAL", 5.0, 0.0, Double.MAX_VALUE / 4.0) + val RADIUS_VERTICAL: Double by builder.defineInRange("RADIUS_VERTICAL", 2.0, 0.0, Double.MAX_VALUE / 4.0) + + init { + builder.pop() + } + } + init { Upgrades + EssenceStorage } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index b77390770..69270ee06 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -163,6 +163,8 @@ public net.minecraft.world.entity.boss.wither.WitherBoss f_31432_ # TARGETING_CO public-f net.minecraft.world.entity.boss.wither.WitherBoss f_31431_ # LIVING_ENTITY_SELECTOR public net.minecraft.world.entity.ai.targeting.TargetingConditions f_26879_ # selector +public net.minecraft.world.entity.ExperienceOrb f_147072_ # count + public net.minecraft.advancements.critereon.InventoryChangeTrigger$TriggerInstance f_43179_ public net.minecraft.advancements.critereon.InventoryChangeTrigger$TriggerInstance f_43178_ public net.minecraft.advancements.critereon.InventoryChangeTrigger$TriggerInstance f_43177_