Skip to content

Commit

Permalink
- 添加 Psi 的一个放置术式测试修复。
Browse files Browse the repository at this point in the history
- 添加 SpecialMobs 的一段测试代码。
  • Loading branch information
KasumiNova committed Nov 2, 2024
1 parent 8834002 commit d1df60f
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 2 deletions.
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {

// Project properties
group = "github.kasuminova.stellarcore"
version = "1.5.13"
version = "1.5.14"

// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod
java {
Expand Down Expand Up @@ -281,6 +281,7 @@ dependencies {
compileOnly(rfg.deobf("curse.maven:electroblobs-wizardry-265642:5354477"))
compileOnly(rfg.deobf("curse.maven:ender-utilities-224320:2977010"))
compileOnly(rfg.deobf("curse.maven:ancient-spellcraft-358124:5413256"))
compileOnly(rfg.deobf("curse.maven:psi-241665:3085917"))
compileOnly(rfg.deobf("curse.maven:random-psideas-302313:3215550"))
compileOnly(rfg.deobf("curse.maven:journeymap-32274:5172461"))
compileOnly(rfg.deobf("curse.maven:abyssalcraft-53686:5330323"))
Expand All @@ -291,6 +292,7 @@ dependencies {
runtimeOnly(rfg.deobf("curse.maven:spark-361579:3245793"))
compileOnly(rfg.deobf("curse.maven:dme-737252:5043404"))
compileOnly(rfg.deobf("curse.maven:bountifulbaubles-313536:3568240"))
compileOnly(rfg.deobf("curse.maven:special-mobs-59968:3320102"))
}

// IDE Settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ public boolean loaded() {
return super.loaded();
}
},
NCO( "nuclearcraft") {
@Override
public boolean loaded() {
if (!super.loaded()) {
return false;
}
return this.loaded = Loader.instance().getIndexedModList().get(modID).getVersion().contains("2o");
}
}
;

final String modID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ public class StellarCoreLateMixinLoader implements ILateMixinLoader {
addMixinCFG( "mixins.stellar_core_mekanism.json", () -> Mods.MEK.loaded() && !Mods.MEKCEU.loaded());
addModdedMixinCFG("mixins.stellar_core_mets.json", "mets");
addModdedMixinCFG("mixins.stellar_core_modularrouters.json", "modularrouters");
addModdedMixinCFG("mixins.stellar_core_nco.json", "nuclearcraft");
addMixinCFG( "mixins.stellar_core_nco.json", Mods.NCO::loaded);
addModdedMixinCFG("mixins.stellar_core_psi.json", "psi");
addModdedMixinCFG("mixins.stellar_core_rgb_chat.json", "jianghun");
addModdedMixinCFG("mixins.stellar_core_scalingguis.json", "scalingguis");
addModdedMixinCFG("mixins.stellar_core_specialmobs.json", "specialmobs");
addModdedMixinCFG("mixins.stellar_core_sync.json", "sync");
addModdedMixinCFG("mixins.stellar_core_sync_techguns.json", "sync", "techguns");
addModdedMixinCFG("mixins.stellar_core_tconevo.json", "tconevo");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package github.kasuminova.stellarcore.mixin.psi;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import vazkii.psi.common.spell.trick.block.PieceTrickPlaceBlock;

@Mixin(PieceTrickPlaceBlock.class)
public abstract class MixinPieceTrickPlaceBlock {

@Inject(
method = "placeBlock(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;IZZ)V",
at = @At(
value = "INVOKE",
target = "Lvazkii/psi/common/spell/trick/block/PieceTrickPlaceBlock;removeFromInventory(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/item/ItemStack;)Lnet/minecraft/item/ItemStack;"
),
remap = false,
cancellable = true
)
private static void injectPlaceBlock(final EntityPlayer player, final World world, final BlockPos pos, final int slot, final boolean particles, final boolean conjure, final CallbackInfo ci) {
ItemStack itemBlockStack = player.inventory.getStackInSlot(slot);
ItemBlock itemBlock = (ItemBlock) itemBlockStack.getItem();
EnumHand hand = player.getActiveHand();
switch (hand) {
case MAIN_HAND -> stellar_core$swapItemStack(player, player.inventory.currentItem, slot);
case OFF_HAND -> stellar_core$swapItemStack(player, 0, slot);
}

if (!world.mayPlace(itemBlock.getBlock(), pos, false, EnumFacing.UP, player)) {
ci.cancel();
}

switch (hand) {
case MAIN_HAND -> stellar_core$swapItemStack(player, player.inventory.currentItem, slot);
case OFF_HAND -> stellar_core$swapItemStack(player, 0, slot);
}
}

@Unique
private static void stellar_core$swapItemStack(final EntityPlayer player, final int currItemIdx, final int slot) {
InventoryPlayer inventory = player.inventory;

ItemStack tmp = inventory.getStackInSlot(slot);
inventory.setInventorySlotContents(slot, inventory.getStackInSlot(currItemIdx));
inventory.setInventorySlotContents(currItemIdx, tmp);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package github.kasuminova.stellarcore.mixin.specialmobs;

import com.llamalad7.mixinextras.sugar.Local;
import fathertoast.specialmobs.SpecialMobReplacer;
import fathertoast.specialmobs.bestiary.EnumMobFamily;
import github.kasuminova.stellarcore.common.util.StellarLog;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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;

@SuppressWarnings("MethodMayBeStatic")
@Mixin(SpecialMobReplacer.class)
public class MixinSpecialMobReplacer {

@Inject(
method = "replace",
at = @At(
value = "INVOKE",
target = "Lorg/apache/logging/log4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V"
),
remap = false
)
private void injectReplace(final EnumMobFamily mobFamily, final boolean isSpecial, final Entity entityToReplace, final World world, final BlockPos entityPos,
final CallbackInfo ci,
@Local(name = "var11") final Exception var11) {
StellarLog.LOG.warn("Logging exception for SpecialMobs mod.", var11);
}

}
10 changes: 10 additions & 0 deletions src/main/resources/mixins.stellar_core_psi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"package": "github.kasuminova.stellarcore.mixin.psi",
"refmap": "mixins.stellar_core.refmap.json",
"target": "@env(DEFAULT)",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": [
"MixinPieceTrickPlaceBlock"
]
}
10 changes: 10 additions & 0 deletions src/main/resources/mixins.stellar_core_specialmobs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"package": "github.kasuminova.stellarcore.mixin.specialmobs",
"refmap": "mixins.stellar_core.refmap.json",
"target": "@env(DEFAULT)",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": [
"MixinSpecialMobReplacer"
]
}

0 comments on commit d1df60f

Please # to comment.