Skip to content

Commit

Permalink
🐛 Fix Sometime will not drop power normally
Browse files Browse the repository at this point in the history
  • Loading branch information
H2Sxxa committed Oct 15, 2023
1 parent 4efb2d7 commit f8947a0
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 7 deletions.
91 changes: 91 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
4 changes: 4 additions & 0 deletions src/main/java/io/github/teamgensouspark/kekkai/Kekkai.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
}

0 comments on commit f8947a0

Please sign in to comment.