mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 01:04:29 +00:00
Host the batch 4 IrisApi: api and host artifacts, ModuleLoadException
- Depend on com.volmit:iris-api and com.volmit:iris-host; the probe compiles against the api only. - PackModuleSet catches ModuleLoadException. - ObjectPlacerEdit implements set(x, y, z, state) without a PlacedBlock; block entities sit in their own map. - BlockStateHunk implements width(), height(), depth().
This commit is contained in:
1 parent
4bacc306e9
commit
64658013fe
16 files changed
+78
-45
No files matched your search
@@ -49,17 +49,17 @@ final class BlockStateHunk implements Hunk<BlockState> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
public int width() {
|
||||
return blocks.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
public int height() {
|
||||
return blocks.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDepth() {
|
||||
public int depth() {
|
||||
return blocks.getDepth();
|
||||
}
|
||||
|
||||
@@ -79,9 +79,9 @@ final class BlockStateHunk implements Hunk<BlockState> {
|
||||
}
|
||||
|
||||
private void requireInside(int x, int y, int z) {
|
||||
if (x < 0 || y < 0 || z < 0 || x >= getWidth() || y >= getHeight() || z >= getDepth()) {
|
||||
if (x < 0 || y < 0 || z < 0 || x >= width() || y >= height() || z >= depth()) {
|
||||
throw new IndexOutOfBoundsException("Block " + x + ", " + y + ", " + z + " is outside the "
|
||||
+ getWidth() + "x" + getHeight() + "x" + getDepth() + " chunk hunk");
|
||||
+ width() + "x" + height() + "x" + depth() + " chunk hunk");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,12 +25,14 @@ import art.arcane.volmlib.util.matter.MatterMarker;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.mantle.Mantle;
|
||||
import com.volmit.object.BlockEntityData;
|
||||
import com.volmit.placement.PlacedBlock;
|
||||
import com.volmit.placement.PlacedMarker;
|
||||
import com.volmit.placement.PlacementEdit;
|
||||
import com.volmit.world.BlockPosition;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -52,7 +54,8 @@ final class ObjectPlacerEdit implements PlacementEdit {
|
||||
private final PlatformBlockStates states;
|
||||
private final BiConsumer<art.arcane.volmlib.util.math.BlockPosition, PlatformBlockState> listener;
|
||||
private final Supplier<PlacementMantle> mantleSource;
|
||||
private final Map<BlockPosition, PlacedBlock> blocks = new LinkedHashMap<>();
|
||||
private final Map<BlockPosition, BlockState> blocks = new LinkedHashMap<>();
|
||||
private final Map<BlockPosition, BlockEntityData> blockEntities = new HashMap<>();
|
||||
private final List<PlacedMarker> markers = new ArrayList<>();
|
||||
private final List<BlockPosition> objectBlocks = new ArrayList<>();
|
||||
private PlacementMantle mantle;
|
||||
@@ -82,15 +85,28 @@ final class ObjectPlacerEdit implements PlacementEdit {
|
||||
@Override
|
||||
public BlockState get(int x, int y, int z) {
|
||||
requireInside(x, y, z);
|
||||
PlacedBlock buffered = blocks.get(new BlockPosition(x, y, z));
|
||||
return buffered != null ? buffered.state() : states.toApi(placer.get(x, y, z));
|
||||
BlockState buffered = blocks.get(new BlockPosition(x, y, z));
|
||||
return buffered != null ? buffered : states.toApi(placer.get(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int x, int y, int z, BlockState state) {
|
||||
requireInside(x, y, z);
|
||||
buffer(new BlockPosition(x, y, z), state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(PlacedBlock block) {
|
||||
BlockPosition position = block.position();
|
||||
requireInside(position.x(), position.y(), position.z());
|
||||
blocks.put(position, block);
|
||||
buffer(position, block.state());
|
||||
block.blockEntity().ifPresent(entity -> blockEntities.put(position, entity));
|
||||
}
|
||||
|
||||
/** A write without a block entity drops one buffered earlier at the same place. */
|
||||
private void buffer(BlockPosition position, BlockState state) {
|
||||
blocks.put(position, state);
|
||||
blockEntities.remove(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,6 +147,7 @@ final class ObjectPlacerEdit implements PlacementEdit {
|
||||
public void close() {
|
||||
discardMantle();
|
||||
blocks.clear();
|
||||
blockEntities.clear();
|
||||
markers.clear();
|
||||
objectBlocks.clear();
|
||||
state = State.CLOSED;
|
||||
@@ -150,11 +167,13 @@ final class ObjectPlacerEdit implements PlacementEdit {
|
||||
}
|
||||
|
||||
private void writeBlocks() {
|
||||
for (PlacedBlock block : blocks.values()) {
|
||||
BlockPosition position = block.position();
|
||||
placer.set(position.x(), position.y(), position.z(), states.toPlatform(block.state()));
|
||||
block.blockEntity().ifPresent(entity -> placer.setTile(position.x(), position.y(), position.z(), BlockEntities.tileOf(entity)));
|
||||
}
|
||||
blocks.forEach((position, block) -> {
|
||||
placer.set(position.x(), position.y(), position.z(), states.toPlatform(block));
|
||||
BlockEntityData entity = blockEntities.get(position);
|
||||
if (entity != null) {
|
||||
placer.setTile(position.x(), position.y(), position.z(), BlockEntities.tileOf(entity));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void writeMarkers() {
|
||||
@@ -169,9 +188,8 @@ final class ObjectPlacerEdit implements PlacementEdit {
|
||||
return;
|
||||
}
|
||||
for (BlockPosition position : objectBlocks) {
|
||||
PlacedBlock written = blocks.get(position);
|
||||
listener.accept(new art.arcane.volmlib.util.math.BlockPosition(position.x(), position.y(), position.z()),
|
||||
states.toPlatform(written.state()));
|
||||
states.toPlatform(blocks.get(position)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ package art.arcane.iris.core.modules;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleLoadException;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
@@ -124,7 +125,7 @@ public final class PackModuleSet implements AutoCloseable {
|
||||
pack = loaded;
|
||||
state = State.LOADED;
|
||||
warnWhenBuiltInModulesAreMissing(loaded);
|
||||
} catch (RuntimeException loadFailure) {
|
||||
} catch (ModuleLoadException loadFailure) {
|
||||
failure = new PackModulesException(packFolder, loadFailure);
|
||||
state = State.FAILED;
|
||||
IrisLogging.error(failure.getMessage());
|
||||
|
||||
@@ -18,11 +18,13 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import com.volmit.host.ModuleLoadException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/** A pack whose modules failed to load. The message names the pack and carries IrisApi's load error. */
|
||||
public final class PackModulesException extends RuntimeException {
|
||||
public PackModulesException(File packFolder, RuntimeException cause) {
|
||||
public PackModulesException(File packFolder, ModuleLoadException cause) {
|
||||
super("Pack " + packFolder.getName() + " cannot load its modules: " + cause.getMessage(), cause);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user