Skip to content
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 @@ -10,6 +10,7 @@
import dev.ryanhcode.sable.companion.math.BoundingBox3ic;
import dev.ryanhcode.sable.companion.math.JOMLConversion;
import dev.ryanhcode.sable.companion.math.Pose3d;
import dev.ryanhcode.sable.index.SableTags;
import dev.ryanhcode.sable.platform.SableAssemblyPlatform;
import dev.ryanhcode.sable.sublevel.ServerSubLevel;
import dev.ryanhcode.sable.sublevel.SubLevel;
Expand Down Expand Up @@ -348,11 +349,19 @@ public static void moveBlocks(final ServerLevel level, final AssemblyTransform t
tag.putInt("z", newPos.getZ());
}

if (blockEntity instanceof final RandomizableContainer container) {
container.setLootTable(null);
}
if (blockEntity instanceof final Clearable clearable) {
clearable.clearContent();
if (state.is(SableTags.SILENT_ASSEMBLY_REMOVAL)) {
level.removeBlockEntity(block);
} else {
// This is the "correct" way to remove a block from the world, but many mods do not implement
// Clearable correctly. The above tag exists to allow this issue to be "fixed" on a case-by-case
// basis without updating a mod's code
//
// A real solution is to implement Clearable on all block entities that can be cleared in the
// same way as Vanilla MC. See SetBlockCommand
if (blockEntity instanceof final RandomizableContainer container) {
container.setLootTable(null);
}
Clearable.tryClear(blockEntity);
}

final LevelChunk chunk = resultingAccelerator.getChunk(SectionPos.blockToSectionCoord(newPos.getX()), SectionPos.blockToSectionCoord(newPos.getZ()));
Expand Down
5 changes: 5 additions & 0 deletions common/src/main/java/dev/ryanhcode/sable/index/SableTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public class SableTags {
Sable.sablePath("paddles")
);

public static final TagKey<Block> SILENT_ASSEMBLY_REMOVAL = TagKey.create(
Registries.BLOCK,
Sable.sablePath("silent_assembly_removal")
);

public static void register() {
// no-op
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"replace": false,
"values": [
{ "id": "createaddition:rolling_mill", "required": false },
{ "id": "rubberworks:compressor", "required": false },
{ "id": "dndesires:smart_hopper", "required": false },
{ "id": "dndesires:roll_table", "required": false },
{ "id": "createfood:ration_box", "required": false },
{ "id": "createfood:cloth_sack", "required": false },
{ "id": "mechanical_botany:mechanical_insolator", "required": false },
{ "id": "mechanical_botany:mechanical_composter", "required": false },
{ "id": "create_connected:item_silo", "required": false },
{ "id": "create_integrated_farming:chicken_roost", "required": false },
{ "id": "create_new_age:reactor_fuel_acceptor", "required": false },
{ "id": "trading_floor:trading_depot", "required": false },
{ "id": "create_fantasizing:transporter", "required": false },
{ "id": "createdieselgenerators:bulk_fermenter", "required": false },
{ "id": "createrailwaysnavigator:navigator_lectern", "required": false },
{ "id": "pipeorgans:tracker_bar", "required": false },
{ "id": "dndecor:colored_storage_container", "required": false }
]
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fabric_version=0.110.0+1.21.1
fabric_loader_version=0.16.9

# NeoForge, see https://projects.neoforged.net/neoforged/neoforge for new versions
neoforge_version=21.1.220
neoforge_version=21.1.228
neoforge_loader_version_range=[4,)

# Dependencies
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package dev.ryanhcode.sable.neoforge.gametest;

import dev.ryanhcode.sable.companion.math.Pose3d;
import dev.ryanhcode.sable.api.sublevel.SubLevelContainer;
import dev.ryanhcode.sable.companion.math.Pose3d;
import dev.ryanhcode.sable.sublevel.ServerSubLevel;
import dev.ryanhcode.sable.sublevel.SubLevel;
import dev.ryanhcode.sable.sublevel.plot.LevelPlot;
import dev.ryanhcode.sable.sublevel.storage.SubLevelRemovalReason;
import net.minecraft.core.BlockPos;
import net.minecraft.gametest.framework.GameTestHelper;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.CommonLevelAccessor;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import org.joml.Vector2i;
import org.joml.Vector3d;
import org.joml.Vector3dc;

import java.util.function.Consumer;

public final class SableTestHelper {
Expand Down Expand Up @@ -78,4 +79,10 @@ public static boolean isInBounds(final GameTestHelper helper, final Vector3dc gl
final AABB box = helper.getBounds();
return box.contains(globalPosition.x(), globalPosition.y(), globalPosition.z());
}

public static void removeSubLevel(final SubLevelContainer container, final ServerSubLevel subLevel) {
final LevelPlot plot = subLevel.getPlot();
final Vector2i origin = container.getOrigin();
container.removeSubLevel(plot.plotPos.x - origin.x, plot.plotPos.z - origin.y, SubLevelRemovalReason.REMOVED);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package dev.ryanhcode.sable.neoforge.gametest;

import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerBossEvent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.PlayerList;
import net.minecraft.world.BossEvent;

public class TestProgressBar {

private final ServerBossEvent bossEvent;
private final PlayerList playerList;
private long maxItems;

public TestProgressBar(final PlayerList playerList) {
this.bossEvent = new ServerBossEvent(Component.literal("Test Progress"), BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.PROGRESS);
this.playerList = playerList;
}

private void updateVisible() {
for (final ServerPlayer player : this.playerList.getPlayers()) {
this.bossEvent.addPlayer(player);
}
}

public void begin(final long maxItems) {
this.maxItems = maxItems;
this.bossEvent.setName(Component.literal("Test Progress: 0 / " + maxItems));
this.updateVisible();
}

public void update(final long items) {
this.updateVisible();
this.bossEvent.setName(Component.literal("Test Progress: " + items + " / " + this.maxItems));
this.bossEvent.setProgress((float) items / this.maxItems);
}

public void end() {
this.bossEvent.removeAllPlayers();
}
}