Skip to content

Commit

Permalink
- #11, untested.
Browse files Browse the repository at this point in the history
  • Loading branch information
KasumiNova committed Sep 22, 2024
1 parent e3e2d52 commit ec8b32a
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 1 deletion.
2 changes: 1 addition & 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.4.9"
version = "1.4.10"

// 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
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,10 @@ public static class Techguns {
@Config.Name("InvalidRecipeFixes")
public boolean fixAmmoSumRecipeFactory = true;

@Config.Comment("Fixes an issue that would cause crashes in server environments.")
@Config.Name("ServerSideEntityCrashFixes")
public boolean serverSideEntityCrashFixes = true;

}

public static class TheOneProbe {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package github.kasuminova.stellarcore.mixin.techguns;

import github.kasuminova.stellarcore.common.config.StellarCoreConfig;
import net.minecraft.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import techguns.client.ClientProxy;
import techguns.entities.projectiles.BioGunProjectile;

@Mixin(BioGunProjectile.class)
@SuppressWarnings("MethodMayBeStatic")
public abstract class MixinBioGunProjectile extends Entity {

@SuppressWarnings("DataFlowIssue")
public MixinBioGunProjectile() {
super(null);
}

@Redirect(method = "<init>(Lnet/minecraft/world/World;)V", at = @At(value = "INVOKE", target = "Ltechguns/client/ClientProxy;get()Ltechguns/client/ClientProxy;"))
private ClientProxy injectInitGetProxy() {
if (world.isRemote || !StellarCoreConfig.BUG_FIXES.techguns.serverSideEntityCrashFixes) {
return ClientProxy.get();
}
return null;
}

@Redirect(method = "<init>(Lnet/minecraft/world/World;)V", at = @At(value = "INVOKE", target = "Ltechguns/client/ClientProxy;createFXOnEntity(Ljava/lang/String;Lnet/minecraft/entity/Entity;)V"))
private void injectInitCreateFX(final ClientProxy instance, final String name, final Entity ent) {
if (instance != null || !StellarCoreConfig.BUG_FIXES.techguns.serverSideEntityCrashFixes) {
assert instance != null;
instance.createFXOnEntity(name, ent);
}
}

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

import github.kasuminova.stellarcore.common.config.StellarCoreConfig;
import net.minecraft.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import techguns.client.ClientProxy;
import techguns.entities.projectiles.FlamethrowerProjectile;

@Mixin(FlamethrowerProjectile.class)
@SuppressWarnings("MethodMayBeStatic")
public abstract class MixinFlamethrowerProjectile extends Entity {

@SuppressWarnings("DataFlowIssue")
public MixinFlamethrowerProjectile() {
super(null);
}

@Redirect(method = "<init>(Lnet/minecraft/world/World;)V", at = @At(value = "INVOKE", target = "Ltechguns/client/ClientProxy;get()Ltechguns/client/ClientProxy;"))
private ClientProxy injectInitGetProxy() {
if (world.isRemote || !StellarCoreConfig.BUG_FIXES.techguns.serverSideEntityCrashFixes) {
return ClientProxy.get();
}
return null;
}

@Redirect(method = "<init>(Lnet/minecraft/world/World;)V", at = @At(value = "INVOKE", target = "Ltechguns/client/ClientProxy;createFXOnEntity(Ljava/lang/String;Lnet/minecraft/entity/Entity;)V"))
private void injectInitCreateFX(final ClientProxy instance, final String name, final Entity ent) {
if (instance != null || !StellarCoreConfig.BUG_FIXES.techguns.serverSideEntityCrashFixes) {
assert instance != null;
instance.createFXOnEntity(name, ent);
}
}

}
2 changes: 2 additions & 0 deletions src/main/resources/mixins.stellar_core_techguns.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
"MixinAmmoSumRecipe",
"MixinBioGunProjectile",
"MixinFlamethrowerProjectile",
"MixinTGDamageSource",
"MixinTGExtendedPlayer",
"MixinTGPermissions"
Expand Down

0 comments on commit ec8b32a

Please sign in to comment.