Skip to content

Commit

Permalink
- 修复 Sync 与 Techguns 模组的一个物品栏复制问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
KasumiNova committed Mar 21, 2024
1 parent 6a181cb commit 8d07fa9
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ dependencies {
compileOnly(rfg.deobf("curse.maven:extended-crafting-nomifactory-edition-398267:4592627"))
compileOnly(rfg.deobf("curse.maven:cucumber-272335:2645867"))
compileOnly(rfg.deobf("curse.maven:better-builders-wands-238403:2691084"))
compileOnly(rfg.deobf("curse.maven:sync-229090:2682824"))
}

// Publishing to a Maven repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public static class BugFixes {
@Config.Name("ScalingGuis")
public final ScalingGuis scalingGuis = new ScalingGuis();

@Config.Name("Sync")
public final Sync sync = new Sync();

@Config.Name("Techguns")
public final Techguns techguns = new Techguns();

Expand Down Expand Up @@ -151,6 +154,13 @@ public static class ScalingGuis {

}

public static class Sync {

@Config.Name("TechgunsDuplicationFixes")
public boolean techgunsDuplicationFixes = true;

}

public static class Techguns {

@Config.Name("TGPermissionsCrashFixes")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class StellarCoreLateMixinLoader implements ILateMixinLoader {
addModdedMixinCFG("mixins.stellar_core_oreexcavation.json", "oreexcavation");
addModdedMixinCFG("mixins.stellar_core_rgb_chat.json", "jianghun");
addModdedMixinCFG("mixins.stellar_core_scalingguis.json", "scalingguis");
addModdedMixinCFG("mixins.stellar_core_sync_techguns.json", "sync", "techguns");
addModdedMixinCFG("mixins.stellar_core_techguns.json", "techguns");
addModdedMixinCFG("mixins.stellar_core_theoneprobe.json", "theoneprobe");
addModdedMixinCFG("mixins.stellar_core_thermaldynamics.json", "thermaldynamics");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package github.kasuminova.stellarcore.mixin.cfm;

import com.mrcrayfish.furniture.tileentity.TileEntitySyncClient;
import github.kasuminova.stellarcore.common.config.StellarCoreConfig;
import net.minecraft.block.state.IBlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;

import javax.annotation.Nonnull;

@Mixin(TileEntitySyncClient.class)
public class MixinTileEntitySyncClient extends TileEntity {

@Unique
@Override
public boolean shouldRefresh(@Nonnull final World world,
@Nonnull final BlockPos pos,
@Nonnull final IBlockState oldState,
@Nonnull final IBlockState newSate)
{
if (!StellarCoreConfig.BUG_FIXES.mrCrayfishFurniture.tileEntityFurniture) {
return super.shouldRefresh(world, pos, oldState, newSate);
}
return oldState.getBlock() != newSate.getBlock();
}

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

import com.llamalad7.mixinextras.sugar.Local;
import github.kasuminova.stellarcore.common.config.StellarCoreConfig;
import me.ichun.mods.sync.common.tileentity.TileEntityDualVertical;
import net.minecraft.entity.player.EntityPlayerMP;
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;
import techguns.api.capabilities.ITGExtendedPlayer;
import techguns.capabilities.TGExtendedPlayerCapProvider;


@Mixin(TileEntityDualVertical.class)
@SuppressWarnings("MethodMayBeStatic")
public class MixinTileEntityDualVertical {

@Inject(method = "update",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/entity/player/EntityPlayerMP;writeToNBT(Lnet/minecraft/nbt/NBTTagCompound;)Lnet/minecraft/nbt/NBTTagCompound;"
)
)
private void injectUpdateClearInventory(final CallbackInfo ci, @Local(name = "dummy") EntityPlayerMP dummy) {
if (!StellarCoreConfig.BUG_FIXES.sync.techgunsDuplicationFixes) {
return;
}
ITGExtendedPlayer tgCap = dummy.getCapability(TGExtendedPlayerCapProvider.TG_EXTENDED_PLAYER, null);
if (tgCap != null) {
tgCap.getTGInventory().clear();
}
}

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

0 comments on commit 8d07fa9

Please sign in to comment.