Skip to content
Open
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 @@ -353,6 +353,8 @@ public static void moveBlocks(final ServerLevel level, final AssemblyTransform t
}
if (blockEntity instanceof final Clearable clearable) {
clearable.clearContent();
}else if (blockEntity != null) {
SableAssemblyPlatform.INSTANCE.clearNonClearableContainerItems(blockEntity,tag);
}

final LevelChunk chunk = resultingAccelerator.getChunk(SectionPos.blockToSectionCoord(newPos.getX()), SectionPos.blockToSectionCoord(newPos.getZ()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package dev.ryanhcode.sable.platform;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.jetbrains.annotations.ApiStatus;

@ApiStatus.Internal
public interface SableAssemblyPlatform {
SableAssemblyPlatform INSTANCE = SablePlatformUtil.load(SableAssemblyPlatform.class);

void setIgnoreOnPlace(final Level level, final boolean ignore);

void clearNonClearableContainerItems(final BlockEntity blockEntity,final CompoundTag tag);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import dev.ryanhcode.sable.fabric.mixinterface.LevelExtension;
import dev.ryanhcode.sable.platform.SableAssemblyPlatform;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.jetbrains.annotations.ApiStatus;

@ApiStatus.Internal
Expand All @@ -12,4 +14,16 @@ public class SableAssemblyPlatformImpl implements SableAssemblyPlatform {
public void setIgnoreOnPlace(final Level level, final boolean ignore) {
((LevelExtension) level).sable$setIgnoreOnPlace(ignore);
}

@Override
public void clearNonClearableContainerItems(final BlockEntity blockEntity,final CompoundTag tag) {
try {
final Level level = blockEntity.getLevel();
if (level == null) return;
final String id = tag.getString("id");
final CompoundTag newTag = new CompoundTag();
newTag.putString("id", id);
blockEntity.loadWithComponents(newTag, level.registryAccess());
} catch (final Exception ignored) {}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package dev.ryanhcode.sable.neoforge.platform;

import dev.ryanhcode.sable.platform.SableAssemblyPlatform;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.jetbrains.annotations.ApiStatus;

@ApiStatus.Internal
Expand All @@ -11,4 +13,16 @@ public class SableAssemblyPlatformImpl implements SableAssemblyPlatform {
public void setIgnoreOnPlace(final Level level, final boolean ignore) {
level.captureBlockSnapshots = ignore;
}

@Override
public void clearNonClearableContainerItems(final BlockEntity blockEntity,final CompoundTag tag) {
try {
final Level level = blockEntity.getLevel();
if (level == null) return;
final String id = tag.getString("id");
final CompoundTag newTag = new CompoundTag();
newTag.putString("id", id);
blockEntity.loadWithComponents(newTag, level.registryAccess());
} catch (final Exception ignored) {}
}
}