Skip to content

Commit

Permalink
Fix RequiousFrakto/Tinkers leaking server world to particles
Browse files Browse the repository at this point in the history
- Particles are client-side; in SP/integrated server cases these mods could leak the server's world to the client when creating particles.
- Fixes Red-Studio-Ragnarok/Alfheim#48
- Fixes Red-Studio-Ragnarok/Alfheim#50
  • Loading branch information
jchung01 committed Jun 14, 2024
1 parent 77d1825 commit bdf52af
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ dependencies {
compileOnly rfg.deobf('curse.maven:openblocks-228816:2699056')
compileOnly rfg.deobf('curse.maven:reborn-core-237903:3330308')
compileOnly rfg.deobf('curse.maven:reskillable-286382:2815686')
compileOnly rfg.deobf('curse.maven:requious-frakto-336748:3218640')
compileOnly rfg.deobf('curse.maven:roost-277711:2702080')
compileOnly rfg.deobf('curse.maven:simpledifficulty-360779:3613814')
compileOnly rfg.deobf('curse.maven:storage-drawers-223852:2952606')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ public class UTConfigMods
@Config.Name("Railcraft")
public static final RailcraftCategory RAILCRAFT = new RailcraftCategory();

@Config.LangKey("cfg.universaltweaks.modintegration.requiousfrakto")
@Config.Name("Requious Frakto")
public static final RequiousFraktoCategory REQUIOUS_FRAKTO = new RequiousFraktoCategory();

@Config.LangKey("cfg.universaltweaks.modintegration.rftoolsdimensions")
@Config.Name("RFTools Dimensions")
public static final RFToolsDimensionsCategory RFTOOLS_DIMENSIONS = new RFToolsDimensionsCategory();
Expand Down Expand Up @@ -654,6 +658,14 @@ public static class RailcraftCategory
public boolean utNoBetaWarningToggle = true;
}

public static class RequiousFraktoCategory
{
@Config.RequiresMcRestart
@Config.Name("Particle Fixes")
@Config.Comment("Fixes server world being leaked to various particles")
public boolean utParticleFixesToggle = true;
}

public static class RoostCategory
{
@Config.RequiresMcRestart
Expand Down Expand Up @@ -942,6 +954,11 @@ public static class TinkersConstructCategory
@Config.Comment("Fixes various duplication exploits")
public boolean utDuplicationFixesToggle = true;

@Config.RequiresMcRestart
@Config.Name("Particle Fixes")
@Config.Comment("Fixes server world being leaked to various particles")
public boolean utParticleFixesToggle = true;

@Config.RequiresMcRestart
@Config.Name("Tool Customization")
@Config.Comment("Enables usage of tweaks in below category to customize Tinkers' tools stats")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class UTMixinLoader implements ILateMixinLoader
put("mixins.mods.modularrouters.json", () -> loaded("modularrouters") && UTConfigMods.MODULAR_ROUTERS.utParticleThreadToggle);
put("mixins.mods.roost.json", () -> loaded("roost") && loaded("contenttweaker"));
put("mixins.mods.storagedrawers.client.json", () -> loaded("storagedrawers"));
put("mixins.mods.tconstruct.client.json", () -> loaded("tconstruct") && UTConfigMods.TINKERS_CONSTRUCT.utParticleFixesToggle);
put("mixins.mods.thaumcraft.entities.client.json", () -> loaded("thaumcraft"));
}
});
Expand Down Expand Up @@ -77,6 +78,7 @@ public class UTMixinLoader implements ILateMixinLoader
put("mixins.mods.nuclearcraft.json", () -> loaded("nuclearcraft"));
put("mixins.mods.openblocks.json", () -> loaded("openblocks") && UTConfigMods.OPEN_BLOCKS.utLastStandFixToggle);
put("mixins.mods.quark.dupes.json", () -> loaded("quark") && UTConfigMods.QUARK.utDuplicationFixesToggle);
put("mixins.mods.requiousfrakto.json", () -> loaded("requious") && UTConfigMods.REQUIOUS_FRAKTO.utParticleFixesToggle);
put("mixins.mods.reskillable.json", () -> loaded("reskillable"));
put("mixins.mods.rftoolsdimensions.json", () -> loaded("rftoolsdim"));
put("mixins.mods.roost.contenttweaker.json", () -> loaded("contenttweaker"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package mod.acgaming.universaltweaks.mods.requiousfrakto.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.tileentity.TileEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import requious.tile.TileEntityAssembly;

// Courtesy of jchung01
@Mixin(value = TileEntityAssembly.class)
public abstract class UTTileEntityAssemblyMixin extends TileEntity
{
/**
* @reason Updating MachineVisuals should only be needed client-side.
* This is the earliest we can check the side before calls to IProxy
* methods for spawning particles.
*/
@ModifyExpressionValue(method = "update", at = @At(value = "INVOKE", target = "Ljava/util/Iterator;hasNext()Z", remap = false))
private boolean utCheckSide(boolean original)
{
if (!this.world.isRemote) return false;
return original;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package mod.acgaming.universaltweaks.mods.tconstruct.mixin;

import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import net.minecraft.client.Minecraft;
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;
import slimeknights.tconstruct.common.ClientProxy;

// Courtesy of jchung01
@Mixin(value = ClientProxy.class, remap = false)
public class UTClientProxyMixin
{
/**
* @reason It is never correct to use passed worlds for particles, only use the client's.
* Ideally we would check sides in the relevant methods before even calling this,
* but this is simpler.
*/
@Inject(method = "spawnParticle", at = @At(value = "HEAD"))
private void utSetWorld(CallbackInfo ci, @Local(argsOnly = true) LocalRef<World> worldRef)
{
worldRef.set(Minecraft.getMinecraft().world);
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/universaltweaks/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ cfg.universaltweaks.modintegration.projectred=ProjectRed
cfg.universaltweaks.modintegration.quark=Quark
cfg.universaltweaks.modintegration.rftoolsdimensions=RFTools Dimensions
cfg.universaltweaks.modintegration.railcraft=Railcraft
cfg.universaltweaks.modintegration.requiousfrakto=Requious Frakto
cfg.universaltweaks.modintegration.roost=Roost
cfg.universaltweaks.modintegration.sd=Storage Drawers
cfg.universaltweaks.modintegration.simpledifficulty=Simple Difficulty
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/mixins.mods.requiousfrakto.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.mods.requiousfrakto.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTTileEntityAssemblyMixin"]
}
7 changes: 7 additions & 0 deletions src/main/resources/mixins.mods.tconstruct.client.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.mods.tconstruct.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"client": ["UTClientProxyMixin"]
}

0 comments on commit bdf52af

Please sign in to comment.