Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashes with CCL, TE tweaks #532

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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