Skip to content

Commit

Permalink
- EnderIO 导管性能进一步优化。
Browse files Browse the repository at this point in the history
- 修复 Sync 模组与 Techguns 的物品栏复制问题。
- 修复 Sync 模组骑乘状态下死亡导致的奇怪问题。
- 使 CFM 的可旋转家具可以被扳手正常旋转。
  • Loading branch information
KasumiNova committed Mar 23, 2024
1 parent 8d07fa9 commit 79aa897
Show file tree
Hide file tree
Showing 18 changed files with 330 additions and 17 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ dependencies {
compileOnly(rfg.deobf("curse.maven:more-electric-tools-366298:3491973"))
compileOnly(rfg.deobf("curse.maven:brandonscore-231382:3051539"))
compileOnly(rfg.deobf("curse.maven:draconicevolution-223565:3051542"))
compileOnly(rfg.deobf("curse.maven:mantle-74924:2713386"))
compileOnly(rfg.deobf("curse.maven:tinkers-construct-74072:2902483"))
compileOnly(rfg.deobf("curse.maven:thermal-dynamics-227443:2920505"))
compileOnly(rfg.deobf("curse.maven:armourers-workshop-229523:3101995"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public static class MrCrayfishFurniture {
@Config.Name("ImageCacheCrashFixes")
public boolean imageCache = true;

@Config.Name("TileEntityFurnitureFixes")
public boolean tileEntityFurniture = true;
@Config.Name("RotatableFurniture")
public boolean rotatableFurniture = true;

@Config.Name("BlockFurnitureTileFixes")
public boolean blockFurnitureTile = true;
Expand Down Expand Up @@ -159,6 +159,9 @@ public static class Sync {
@Config.Name("TechgunsDuplicationFixes")
public boolean techgunsDuplicationFixes = true;

@Config.Name("RidingFixes")
public boolean ridingFixes = true;

}

public static class Techguns {
Expand Down Expand Up @@ -237,7 +240,7 @@ public static class Performance {
public static class Vanilla {

@Config.Name("CapturedBlockSnapshotsImprovements")
public boolean capturedBlockSnapshots = true;
public boolean capturedBlockSnapshots = false;

@Config.Name("CapturedBlockSnapshotsImprovementsOreExcavationIntegration")
public boolean capturedBlockSnapshotsMiningAgentIntegration = true;
Expand Down Expand Up @@ -336,6 +339,9 @@ public static class EnderIOConduits {
@Config.Name("AbstractConduitImprovements")
public boolean abstractConduit = true;

@Config.Name("TileConduitBundleImprovements")
public boolean tileConduitBundle = true;

}

public static class IndustrialCraft2 {
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.json", "sync");
addModdedMixinCFG("mixins.stellar_core_sync_techguns.json", "sync", "techguns");
addModdedMixinCFG("mixins.stellar_core_techguns.json", "techguns");
addModdedMixinCFG("mixins.stellar_core_theoneprobe.json", "theoneprobe");
Expand All @@ -53,7 +54,14 @@ public class StellarCoreLateMixinLoader implements ILateMixinLoader {

static {
if (StellarCoreConfig.FEATURES.hitokoto) {
CompletableFuture.runAsync(HitokotoAPI::getRandomHitokoto);
new Thread(() -> {
Thread.currentThread().setName("Stellar Core Hitokoto Initializer");
String hitokoto = HitokotoAPI.getRandomHitokoto();
if (hitokoto == null || hitokoto.isEmpty()) {
return;
}
LOG.info(LOG_PREFIX + hitokoto);
}).start();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package github.kasuminova.stellarcore.mixin.cfm;

import com.mrcrayfish.furniture.tileentity.TileEntityCookieJar;
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(TileEntityCookieJar.class)
public class MixinTileEntityCookieJar 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.rotatableFurniture) {
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,30 @@
package github.kasuminova.stellarcore.mixin.cfm;

import com.mrcrayfish.furniture.tileentity.TileEntityDeskCabinet;
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(TileEntityDeskCabinet.class)
public class MixinTileEntityDeskCabinet 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.rotatableFurniture) {
return super.shouldRefresh(world, pos, oldState, newSate);
}
return oldState.getBlock() != newSate.getBlock();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public boolean shouldRefresh(@Nonnull final World world,
@Nonnull final IBlockState oldState,
@Nonnull final IBlockState newSate)
{
if (!StellarCoreConfig.BUG_FIXES.mrCrayfishFurniture.tileEntityFurniture) {
if (!StellarCoreConfig.BUG_FIXES.mrCrayfishFurniture.rotatableFurniture) {
return super.shouldRefresh(world, pos, oldState, newSate);
}
return oldState.getBlock() != newSate.getBlock();
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.TileEntityKitchenCounter;
import com.mrcrayfish.furniture.tileentity.TileEntityKitchenCounterDrawer;
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(TileEntityKitchenCounter.class)
public class MixinTileEntityKitchenCounter 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.rotatableFurniture) {
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,30 @@
package github.kasuminova.stellarcore.mixin.cfm;

import com.mrcrayfish.furniture.tileentity.TileEntityCookieJar;
import com.mrcrayfish.furniture.tileentity.TileEntityKitchenCounterDrawer;
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(TileEntityKitchenCounterDrawer.class)
public class MixinTileEntityKitchenCounterDrawer 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.rotatableFurniture) {
return super.shouldRefresh(world, pos, oldState, newSate);
}
return oldState.getBlock() != newSate.getBlock();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public boolean shouldRefresh(@Nonnull final World world,
@Nonnull final IBlockState oldState,
@Nonnull final IBlockState newSate)
{
if (!StellarCoreConfig.BUG_FIXES.mrCrayfishFurniture.tileEntityFurniture) {
if (!StellarCoreConfig.BUG_FIXES.mrCrayfishFurniture.rotatableFurniture) {
return super.shouldRefresh(world, pos, oldState, newSate);
}
return oldState.getBlock() != newSate.getBlock();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package github.kasuminova.stellarcore.mixin.cfm;

import com.mrcrayfish.furniture.tileentity.TileEntityTVStand;
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(TileEntityTVStand.class)
public class MixinTileEntityTVStand 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.rotatableFurniture) {
return super.shouldRefresh(world, pos, oldState, newSate);
}
return oldState.getBlock() != newSate.getBlock();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import github.kasuminova.stellarcore.common.config.StellarCoreConfig;
import github.kasuminova.stellarcore.common.util.HashedItemStack;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -24,13 +26,14 @@ public class MixinOreThing {

@Unique
private final Map<HashedItemStack, Boolean> stellar_core$stackCache = new WeakHashMap<>();
@Unique
private final Map<Block, Boolean> stellar_core$blockCache = new WeakHashMap<>();
@Unique
private final Map<Item, Boolean> stellar_core$itemCache = new WeakHashMap<>();

@Inject(method = "is(Lnet/minecraft/item/ItemStack;)Z", at = @At("HEAD"), cancellable = true, remap = false)
public void injectIs(final ItemStack itemStack, final CallbackInfoReturnable<Boolean> cir) {
if (!StellarCoreConfig.PERFORMANCE.enderCore.oreThing) {
return;
}
if (this.ores.size() <= 4) {
public void injectItemStackIs(final ItemStack itemStack, final CallbackInfoReturnable<Boolean> cir) {
if (stellar_core$checkShouldCached()) {
return;
}

Expand All @@ -39,8 +42,9 @@ public void injectIs(final ItemStack itemStack, final CallbackInfoReturnable<Boo
return;
}
HashedItemStack hashedStack = HashedItemStack.ofMeta(itemStack);
if (stellar_core$stackCache.containsKey(hashedStack)) {
cir.setReturnValue(stellar_core$stackCache.get(hashedStack));
Boolean result = stellar_core$stackCache.get(hashedStack);
if (result != null) {
cir.setReturnValue(result);
}

for (ItemStack oreStack : this.ores) {
Expand All @@ -56,4 +60,56 @@ public void injectIs(final ItemStack itemStack, final CallbackInfoReturnable<Boo
cir.setReturnValue(false);
}

@Inject(method = "is(Lnet/minecraft/item/Item;)Z", at = @At("HEAD"), cancellable = true, remap = false)
public void injectItemIs(final Item item, final CallbackInfoReturnable<Boolean> cir) {
if (stellar_core$checkShouldCached()) {
return;
}

Boolean result = stellar_core$itemCache.get(item);
if (result != null) {
cir.setReturnValue(result);
}

for (final ItemStack ore : ores) {
if (item == ore.getItem()) {
stellar_core$itemCache.put(item, true);
cir.setReturnValue(true);
return;
}
}
stellar_core$itemCache.put(item, false);
cir.setReturnValue(false);
}

@Inject(method = "is(Lnet/minecraft/block/Block;)Z", at = @At("HEAD"), cancellable = true, remap = false)
public void injectBlockIs(final Block block, final CallbackInfoReturnable<Boolean> cir) {
if (stellar_core$checkShouldCached()) {
return;
}

Boolean result = stellar_core$blockCache.get(block);
if (result != null) {
cir.setReturnValue(result);
}

for (final ItemStack ore : ores) {
if (Item.getItemFromBlock(block) == ore.getItem() || Block.getBlockFromItem(ore.getItem()) != block) {
stellar_core$blockCache.put(block, true);
cir.setReturnValue(true);
return;
}
}
stellar_core$blockCache.put(block, false);
cir.setReturnValue(false);
}

@Unique
private boolean stellar_core$checkShouldCached() {
if (!StellarCoreConfig.PERFORMANCE.enderCore.oreThing) {
return true;
}
return this.ores.size() <= 4;
}

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

import crazypants.enderio.base.TileEntityEio;
import crazypants.enderio.base.conduit.IConduit;
import crazypants.enderio.conduits.conduit.TileConduitBundle;
import github.kasuminova.stellarcore.common.config.StellarCoreConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Collection;

@Mixin(TileConduitBundle.class)
public abstract class MixinTileConduitBundle extends TileEntityEio {

@Shadow public abstract Collection<? extends IConduit> getConduits();

@Shadow private boolean conduitsDirty;

@Shadow protected abstract void doConduitsDirty();

@Shadow protected abstract void updateEntityClient();

@Inject(method = "doUpdate", at = @At("HEAD"), cancellable = true)
private void injectDoUpdate(final CallbackInfo ci) {
if (!StellarCoreConfig.PERFORMANCE.enderIOConduits.tileConduitBundle) {
return;
}

for (final IConduit conduit : this.getConduits()) {
conduit.updateEntity(this.world);
}

if (!this.world.isRemote && this.conduitsDirty) {
this.doConduitsDirty();
}

if (this.world.isRemote) {
this.updateEntityClient();
}

ci.cancel();
}

}
Loading

0 comments on commit 79aa897

Please sign in to comment.