From 50a6806a0e6ebb131ee055ae95c74daaac822cc3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 26 Sep 2022 11:00:59 +0700 Subject: [PATCH] Phantom attractor android feature --- .../dbotthepony/mc/otm/datagen/ResearchData.kt | 17 +++++++++++++++++ .../dbotthepony/mc/otm/datagen/lang/English.kt | 1 + .../android/feature/PhantomAttractorFeature.kt | 13 +++++++++++++ .../otm/capability/MatteryPlayerCapability.kt | 3 ++- .../mc/otm/client/render/ResearchIcons.kt | 3 +++ .../mc/otm/registry/AndroidFeatures.kt | 1 + 6 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/PhantomAttractorFeature.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt index 1178bdf0a..92fc79785 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt @@ -331,6 +331,20 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang serializer.accept(FALL_DAMPENERS_2) serializer.accept(FALL_DAMPENERS_3) + val PHANTOM_ATTRACTOR = + AndroidResearchType.Builder(modLocation(MNames.PHANTOM_ATTRACTOR)) + .withExperience(20) + .withDescription() + .withIcon(ResearchIcons.ICON_PHANTOM_ATTRACTOR) + .addFeatureResult(AndroidFeatures.PHANTOM_ATTRACTOR) + .addPrerequisite(NANOBOTS) + .addItem(MItems.PHANTOM_ATTRACTOR) + .addItem(MItemTags.COPPER_WIRES, 2) + .addItem(MItemTags.TRITANIUM_PLATES, 2) + .build() + + serializer.accept(PHANTOM_ATTRACTOR) + with(lang.english) { misc("fall_dampeners.description", "Reduces fall damage by %s%%") @@ -382,6 +396,9 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang add(SHOCKWAVE, "description0", "Releases a shockwave around unit, damaging everything in small radius, as unit quickly land on ground") add(SHOCKWAVE, "description1", "It does not, however, help with ground impact damage!") + add(PHANTOM_ATTRACTOR, "Builtin Phantom Attractor") + add(PHANTOM_ATTRACTOR, "description", "Allows unit to attract phantoms while active under same conditions as non-androids") + add(attackBoostList[0], "Attack Boost %s") add(attackBoostList[0], "description", "Increases total melee attack strength by %s%%") } 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 59d397dd4..1f83d381e 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 @@ -482,6 +482,7 @@ private fun androidFeatures(provider: MatteryLanguageProvider) { add(AndroidFeatures.NANOBOTS_ARMOR, "Nanobots Armor") add(AndroidFeatures.ITEM_MAGNET, "Item Magnet") add(AndroidFeatures.STEP_ASSIST, "Step Assist") + add(AndroidFeatures.PHANTOM_ATTRACTOR, "Phantom Attractor") } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/PhantomAttractorFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/PhantomAttractorFeature.kt new file mode 100644 index 000000000..14f8580d3 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/PhantomAttractorFeature.kt @@ -0,0 +1,13 @@ +package ru.dbotthepony.mc.otm.android.feature + +import com.mojang.blaze3d.vertex.PoseStack +import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature +import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability +import ru.dbotthepony.mc.otm.client.render.ResearchIcons +import ru.dbotthepony.mc.otm.registry.AndroidFeatures + +class PhantomAttractorFeature(android: MatteryPlayerCapability) : AndroidSwitchableFeature(AndroidFeatures.PHANTOM_ATTRACTOR, android) { + override fun renderIcon(stack: PoseStack, x: Float, y: Float, width: Float, height: Float) { + ResearchIcons.ICON_PHANTOM_ATTRACTOR.render(stack, x, y, width, height) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 7a846cf31..ed6dcb209 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -44,6 +44,7 @@ import ru.dbotthepony.mc.otm.android.AndroidFeatureType import ru.dbotthepony.mc.otm.android.AndroidResearch import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidResearchType +import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.menu.ExoSuitInventoryMenu @@ -848,7 +849,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial fun canEntitySpawn(event: LivingSpawnEvent.CheckSpawn) { if (event.spawnReason == MobSpawnType.NATURAL && event.entity is Phantom) { for (ply in event.entity.level.players()) { - if (ply.matteryPlayer?.isAndroid == true) { + if (ply.matteryPlayer?.isAndroid == true && (ply.matteryPlayer?.getFeature(AndroidFeatures.PHANTOM_ATTRACTOR) as AndroidSwitchableFeature?)?.isActive != true) { if ( ply.position.y in event.y - 36.0 .. event.y - 19.0 && ply.position.x in event.x - 12.0 .. event.x + 12.0 && diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt index c6095676e..4a6b22633 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt @@ -31,6 +31,9 @@ object ResearchIcons { val ICON_EXTENDED_REACH: SkinElement + val KOT = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/block/ph_kitty.png").element(0f, 0f, 32f, 32f, 32f, 32f) + val ICON_PHANTOM_ATTRACTOR = KOT + init { val grid = SkinGrid(ICONS, 18f, 18f, 7, 7) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt index 07fe2c5b2..7a34fe442 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt @@ -21,6 +21,7 @@ object AndroidFeatures { val SHOCKWAVE: AndroidFeatureType<*> by registry.register(MNames.SHOCKWAVE) { AndroidFeatureType(::ShockwaveFeature) } val ITEM_MAGNET: AndroidFeatureType<*> by registry.register(MNames.ITEM_MAGNET) { AndroidFeatureType(::ItemMagnetFeature) } val FALL_DAMPENERS: AndroidFeatureType<*> by registry.register(MNames.FALL_DAMPENERS) { AndroidFeatureType(::FallDampenersFeature) } + val PHANTOM_ATTRACTOR: AndroidFeatureType<*> by registry.register(MNames.PHANTOM_ATTRACTOR) { AndroidFeatureType(::PhantomAttractorFeature) } internal fun register(bus: IEventBus) { registry.register(bus)