Skip to content

Instantly share code, notes, and snippets.

@tildejustin
Created February 10, 2026 21:18
Show Gist options
  • Select an option

  • Save tildejustin/fa1ec46b7a01ef075034e1ed6d3f4d95 to your computer and use it in GitHub Desktop.

Select an option

Save tildejustin/fa1ec46b7a01ef075034e1ed6d3f4d95 to your computer and use it in GitHub Desktop.
portal frame and silverfish spawner overwrite fix
import com.llamalad7.mixinextras.injector.wrapoperation.*;
import net.minecraft.block.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ServerWorldAccess;
import net.minecraft.world.gen.feature.LakeFeature;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(LakeFeature.class)
public abstract class LakeFeatureMixin {
@WrapOperation(method = "generate(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/world/gen/StructureAccessor;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Ljava/util/Random;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/gen/feature/SingleStateFeatureConfig;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/ServerWorldAccess;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private boolean excludeIrreplaceableBlocks(ServerWorldAccess instance, BlockPos pos, BlockState state, int flags, Operation<Boolean> original) {
return instance.getBlockState(pos).getBlock() != Blocks.END_PORTAL_FRAME && !SpawnerHelper.isSilverfishSpawner(instance, pos) && original.call(instance, pos, state, flags);
}
}
import net.minecraft.world.*;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(MobSpawnerLogic.class)
public interface MobSpawnerLogicAccessor {
@Accessor
MobSpawnerEntry getSpawnEntry();
}
import com.llamalad7.mixinextras.injector.wrapoperation.*;
import net.minecraft.block.*;
import net.minecraft.structure.RuinedPortalStructurePiece;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(RuinedPortalStructurePiece.class)
public abstract class RuinedPortalStructurePieceMixin {
@WrapOperation(method = "placeNetherrackBottom", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/WorldAccess;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private boolean excludeIrreplaceableBlocks(WorldAccess instance, BlockPos pos, BlockState state, int flags, Operation<Boolean> original) {
return instance.getBlockState(pos).getBlock() != Blocks.END_PORTAL_FRAME && !SpawnerHelper.isSilverfishSpawner(instance, pos) && original.call(instance, pos, state, flags);
}
}
import net.minecraft.block.entity.*;
import net.minecraft.entity.EntityType;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView;
public class SpawnerHelper {
public static boolean isSilverfishSpawner(BlockView world, BlockPos pos) {
BlockEntity be = world.getBlockEntity(pos);
if (!(be instanceof MobSpawnerBlockEntity)) return false;
CompoundTag tag = ((MobSpawnerLogicAccessor) ((MobSpawnerBlockEntity) be).getLogic()).getSpawnEntry().getEntityTag();
if (tag == null) return false;
String id = tag.getString("id");
return id != null && id.equals(Registry.ENTITY_TYPE.getId(EntityType.SILVERFISH).toString());
}
}
import com.llamalad7.mixinextras.injector.wrapoperation.*;
import net.minecraft.block.*;
import net.minecraft.structure.Structure;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(Structure.class)
public abstract class StructureMixin {
@WrapOperation(method = "place(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;I)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/WorldAccess;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private boolean excludeIrreplaceableBlocks(WorldAccess instance, BlockPos pos, BlockState state, int flags, Operation<Boolean> original) {
return instance.getBlockState(pos).getBlock() != Blocks.END_PORTAL_FRAME && !SpawnerHelper.isSilverfishSpawner(instance, pos) && original.call(instance, pos, state, flags);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment