From f8947a0b782cf957f27da33f79c402c34fb23a89 Mon Sep 17 00:00:00 2001 From: H2Sxxa Date: Sun, 15 Oct 2023 09:30:16 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Sometime=20will=20not=20dr?= =?UTF-8?q?op=20power=20normally?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 91 +++++++++++++++++++ .../github/teamgensouspark/kekkai/Kekkai.java | 4 + .../kekkai/enums/EnumTouhouCapacity.java | 2 +- .../kekkai/event/KekkaiEvent.java | 16 ++-- .../kekkai/utils/ModCompat.java | 29 ++++++ 5 files changed, 135 insertions(+), 7 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 src/main/java/io/github/teamgensouspark/kekkai/utils/ModCompat.java diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..64b78ee --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,91 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Current File", + "request": "launch", + "mainClass": "${file}" + }, + { + "type": "java", + "name": "GradleStart", + "request": "launch", + "mainClass": "GradleStart", + "projectName": "kekkai" + }, + { + "type": "java", + "name": "GradleStartServer", + "request": "launch", + "mainClass": "GradleStartServer", + "projectName": "kekkai" + }, + { + "type": "java", + "name": "Player", + "request": "launch", + "mainClass": "ibxm.Player", + "projectName": "kekkai" + }, + { + "type": "java", + "name": "Main", + "request": "launch", + "mainClass": "net.minecraft.client.main.Main", + "projectName": "kekkai" + }, + { + "type": "java", + "name": "MinecraftServer", + "request": "launch", + "mainClass": "net.minecraft.server.MinecraftServer", + "projectName": "kekkai" + }, + { + "type": "java", + "name": "AccessTransformer", + "request": "launch", + "mainClass": "net.minecraftforge.fml.common.asm.transformers.AccessTransformer", + "projectName": "kekkai" + }, + { + "type": "java", + "name": "MarkerTransformer", + "request": "launch", + "mainClass": "net.minecraftforge.fml.common.asm.transformers.MarkerTransformer", + "projectName": "kekkai" + }, + { + "type": "java", + "name": "GenDiffSet", + "request": "launch", + "mainClass": "net.minecraftforge.fml.common.patcher.GenDiffSet", + "projectName": "kekkai" + }, + { + "type": "java", + "name": "ServerLaunchWrapper", + "request": "launch", + "mainClass": "net.minecraftforge.fml.relauncher.ServerLaunchWrapper", + "projectName": "kekkai" + }, + { + "type": "java", + "name": "Delta", + "request": "launch", + "mainClass": "net.minecraftforge.fml.repackage.com.nothome.delta.Delta", + "projectName": "kekkai" + }, + { + "type": "java", + "name": "GDiffPatcher", + "request": "launch", + "mainClass": "net.minecraftforge.fml.repackage.com.nothome.delta.GDiffPatcher", + "projectName": "kekkai" + } + ] +} \ No newline at end of file diff --git a/src/main/java/io/github/teamgensouspark/kekkai/Kekkai.java b/src/main/java/io/github/teamgensouspark/kekkai/Kekkai.java index 4ba34d4..8a454d9 100644 --- a/src/main/java/io/github/teamgensouspark/kekkai/Kekkai.java +++ b/src/main/java/io/github/teamgensouspark/kekkai/Kekkai.java @@ -8,6 +8,7 @@ import io.github.teamgensouspark.kekkai.config.KekkaiKeyBindings; import io.github.teamgensouspark.kekkai.example.spellcard.MySpellCards; import io.github.teamgensouspark.kekkai.spellcard.SpellCardModelHelper; +import io.github.teamgensouspark.kekkai.utils.ModCompat; import io.github.teamgensouspark.kekkai.utils.ModResource; @Mod(modid = KekkaiModInfo.MODID, name = KekkaiModInfo.NAME, version = KekkaiModInfo.VERSION, dependencies = "required-after:mirror@[0.4.0,);required-after:danmakucore") @@ -19,6 +20,9 @@ public class Kekkai { @EventHandler public static void PreInit(FMLPreInitializationEvent event) { logger = event.getModLog(); + new ModCompat("mixinbooter") + .ifNotLoadedThen(() -> logger.warn( + "Install MixinBooter to enable patch danmakucore! -> https://modrinth.com/mod/mixinbooter")); SpellCardModelHelper.initSpellCardBake(); MySpellCards.initSpellCard(); KekkaiKeyBindings.initKeyBindings(); diff --git a/src/main/java/io/github/teamgensouspark/kekkai/enums/EnumTouhouCapacity.java b/src/main/java/io/github/teamgensouspark/kekkai/enums/EnumTouhouCapacity.java index db1ee0c..a399e5f 100644 --- a/src/main/java/io/github/teamgensouspark/kekkai/enums/EnumTouhouCapacity.java +++ b/src/main/java/io/github/teamgensouspark/kekkai/enums/EnumTouhouCapacity.java @@ -5,5 +5,5 @@ public enum EnumTouhouCapacity { BIGPOWER, LIFE, BOMB, - SCORE //Can not spawn Entity, use {@link EnumTouhouScore} + SCORE // Can not spawn Entity, use {@link EnumTouhouScore} } diff --git a/src/main/java/io/github/teamgensouspark/kekkai/event/KekkaiEvent.java b/src/main/java/io/github/teamgensouspark/kekkai/event/KekkaiEvent.java index 3d7c89a..1be8cef 100644 --- a/src/main/java/io/github/teamgensouspark/kekkai/event/KekkaiEvent.java +++ b/src/main/java/io/github/teamgensouspark/kekkai/event/KekkaiEvent.java @@ -17,6 +17,7 @@ import net.katsstuff.teamnightclipse.danmakucore.lib.data.LibSubEntities; import net.katsstuff.teamnightclipse.mirror.data.Vector3; import net.minecraft.client.resources.I18n; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -120,12 +121,15 @@ public static void dropPower(LivingDeathEvent event) { if (!living.isNonBoss() || living instanceof EntityPlayer) { if (!living.world.isRemote) { int max = KekkaiModInfo.RND.nextInt(4); - for (int i = 0; i < max; i++) { - KekkaiHelper - .spawnTouhouCapacity(living.world, new Vector3(living), - (Vector3) Vector3.directionToPos(new Vector3(living), - (new Vector3(event.getSource().getImmediateSource()))), - EnumTouhouCapacity.POWER); + Entity source = event.getSource().getImmediateSource(); + if (source != null) { + for (int i = 0; i < max; i++) { + KekkaiHelper + .spawnTouhouCapacity(living.world, new Vector3(living), + (Vector3) Vector3.directionToPos(new Vector3(living), + (new Vector3(source))), + EnumTouhouCapacity.POWER); + } } } } diff --git a/src/main/java/io/github/teamgensouspark/kekkai/utils/ModCompat.java b/src/main/java/io/github/teamgensouspark/kekkai/utils/ModCompat.java new file mode 100644 index 0000000..9edbf9e --- /dev/null +++ b/src/main/java/io/github/teamgensouspark/kekkai/utils/ModCompat.java @@ -0,0 +1,29 @@ +package io.github.teamgensouspark.kekkai.utils; + +import net.minecraftforge.fml.common.Loader; + +public class ModCompat { + public ModResource resource; + private String modid; + + public ModCompat(String modid) { + resource = new ModResource(modid); + this.modid = modid; + } + + public boolean isLoaded() { + return Loader.isModLoaded(modid); + } + + public void ifLoadedThen(Runnable F) { + if (isLoaded()) { + F.run(); + } + } + + public void ifNotLoadedThen(Runnable F) { + if (!isLoaded()) { + F.run(); + } + } +}