Skip to content

Commit

Permalink
Merge pull request #532 from jchung01/mod-tweaks
Browse files Browse the repository at this point in the history
Fix crashes with CCL, TE tweaks
  • Loading branch information
ACGaming authored Jul 30, 2024
2 parents 5886bff + cb762ff commit ba0bdfe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@

import codechicken.lib.packet.PacketCustom;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

/**
* This mixin retains PacketCustom payloads, increasing the ref count by the number of players
Expand Down Expand Up @@ -87,15 +85,8 @@ private static void utRetainForOps(Packet<INetHandler> packet, CallbackInfo ci)
}
}

@Shadow
public abstract boolean release();

/**
* Release this buf after copying it, just to be safe.
*/
@Inject(method = "toPacket", at = @At(value = "RETURN"))
private void utReleaseOriginal(CallbackInfoReturnable<FMLProxyPacket> cir)
{
this.release();
}
// Releasing the PacketCustom on copy to packet would be ideal, but some mods still use the PacketCustom after calling this...
// But there isn't any other good way (AFAIK) to release without knowing a mod's specific usage.
// Excluding this prevents crashes from deallocating too early, but could there be leaks? If so, needs more investigation.
// @Inject(method = "toPacket", at = @At(value = "RETURN"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import net.minecraft.item.ItemStack;

import net.minecraftforge.fml.common.Loader;

import com.blamejared.compat.thermalexpansion.Insolator;
import crafttweaker.annotations.ModOnly;
import crafttweaker.annotations.ZenRegister;
Expand Down Expand Up @@ -56,7 +58,7 @@ public static void addRecipeMonocultureSaplingInfuser(IItemStack primaryOutput,
public static List<ItemStack> getFertilizers()
{
List<ItemStack> fertilizers = Collections.emptyList();
if (additionalFertilizers != null)
if (additionalFertilizers != null && Loader.isModLoaded("crafttweaker"))
{
fertilizers = additionalFertilizers.stream().map(CraftTweakerMC::getItemStack).collect(Collectors.toList());
additionalFertilizers = null;
Expand Down

0 comments on commit ba0bdfe

Please sign in to comment.