Skip to content

Commit 1ac3630

Browse files
committed
Switch to using spatial instead of a copy
1 parent 0801f0d commit 1ac3630

File tree

15 files changed

+49
-363
lines changed

15 files changed

+49
-363
lines changed

core-api/build.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,24 @@ neoForge {
3434
version = neoforged.versions.neoforge
3535
}
3636

37+
repositories {
38+
mavenLocal()
39+
maven("https://maven.pkg.github.com/compactmods/spatial") {
40+
name = "Github PKG - Spatial"
41+
credentials {
42+
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
43+
password = project.findProperty("gpr.token") as String? ?: System.getenv("GITHUB_TOKEN")
44+
}
45+
}
46+
}
47+
48+
dependencies {
49+
compileOnly(compactmods.spatial)
50+
jarJar(compactmods.spatial) { isTransitive = false }
51+
}
52+
53+
54+
3755
tasks.withType<JavaCompile> {
3856
options.encoding = "UTF-8"
3957
options.compilerArgs.add("-proc:none")

core-api/src/main/java/dev/compactmods/machines/api/room/CompactRoomGenerator.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
package dev.compactmods.machines.api.room;
22

33
import dev.compactmods.machines.api.WallConstants;
4-
import dev.compactmods.machines.api.room.spatial.IRoomBoundaries;
5-
import dev.compactmods.machines.api.util.AABBAligner;
6-
import dev.compactmods.machines.api.util.AABBHelper;
74
import dev.compactmods.machines.api.util.BlockSpaceUtil;
8-
import dev.compactmods.machines.api.util.VectorUtils;
5+
import dev.compactmods.spatial.aabb.AABBAligner;
6+
import dev.compactmods.spatial.aabb.AABBHelper;
7+
import dev.compactmods.spatial.vector.VectorUtils;
98
import net.minecraft.core.BlockPos;
109
import net.minecraft.core.Direction;
11-
import net.minecraft.core.Vec3i;
1210
import net.minecraft.core.registries.BuiltInRegistries;
1311
import net.minecraft.resources.ResourceLocation;
1412
import net.minecraft.server.level.ServerLevel;
15-
import net.minecraft.world.level.Level;
1613
import net.minecraft.world.level.LevelAccessor;
1714
import net.minecraft.world.level.block.Block;
1815
import net.minecraft.world.level.block.Blocks;
@@ -21,7 +18,6 @@
2118
import net.minecraft.world.level.block.state.BlockState;
2219
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
2320
import net.minecraft.world.phys.AABB;
24-
import net.minecraft.world.phys.Vec3;
2521
import org.joml.Vector3d;
2622

2723
public class CompactRoomGenerator {
@@ -90,7 +86,7 @@ public static void populateStructure(ServerLevel level, ResourceLocation templat
9086
.setMirror(Mirror.NONE);
9187

9288
AABB placementBounds = null;
93-
final AABBAligner aligner = AABBAligner.create(roomInnerBounds, templateSize);
89+
final AABBAligner.Bounded aligner = AABBAligner.create(roomInnerBounds, AABBHelper.zeroOriginSized(templateSize));
9490
switch (placement) {
9591
case CENTERED -> placementBounds = aligner
9692
.center(roomInnerBounds.getCenter())
@@ -106,7 +102,8 @@ public static void populateStructure(ServerLevel level, ResourceLocation templat
106102
}
107103

108104
if(placementBounds != null) {
109-
BlockPos placeAt = BlockPos.containing(AABBHelper.minCorner(placementBounds));
105+
final var pos = AABBHelper.minCorner(placementBounds);
106+
BlockPos placeAt = BlockPos.containing(pos.x(), pos.y(), pos.z());
110107
tem.placeInWorld(level, placeAt, placeAt, placementSettings, level.random, Block.UPDATE_ALL);
111108
}
112109
});

core-api/src/main/java/dev/compactmods/machines/api/room/RoomTranslations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import dev.compactmods.machines.api.CompactMachines;
44
import dev.compactmods.machines.api.room.function.PlayerAndRoomCodeFunction;
5-
import dev.compactmods.machines.api.util.AABBHelper;
5+
import dev.compactmods.spatial.aabb.AABBHelper;
66
import net.minecraft.ChatFormatting;
77
import net.minecraft.Util;
88
import net.minecraft.core.BlockPos;

core-api/src/main/java/dev/compactmods/machines/api/room/spatial/IRoomBoundaries.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package dev.compactmods.machines.api.room.spatial;
22

3-
import dev.compactmods.machines.api.util.AABBHelper;
3+
import dev.compactmods.spatial.aabb.AABBHelper;
44
import net.minecraft.core.BlockPos;
5-
import net.minecraft.core.Vec3i;
65
import net.minecraft.world.level.ChunkPos;
76
import net.minecraft.world.phys.AABB;
87
import net.minecraft.world.phys.Vec3;

core-api/src/main/java/dev/compactmods/machines/api/util/AABBAligner.java

Lines changed: 0 additions & 76 deletions
This file was deleted.

core-api/src/main/java/dev/compactmods/machines/api/util/AABBHelper.java

Lines changed: 0 additions & 76 deletions
This file was deleted.

core-api/src/main/java/dev/compactmods/machines/api/util/BlockSpaceUtil.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,6 @@ public static Stream<BlockPos> blocksInside(AABB bounds) {
1414
return BlockPos.betweenClosedStream(bounds.contract(1, 1, 1));
1515
}
1616

17-
public static Stream<BlockPos> forAllCorners(AABB bounds) {
18-
Stream.Builder<BlockPos> stream = Stream.builder();
19-
stream.add(BlockPos.containing(bounds.maxX - 1, bounds.maxY - 1, bounds.maxZ - 1));
20-
stream.add(BlockPos.containing(bounds.minX, bounds.maxY - 1, bounds.maxZ - 1));
21-
stream.add(BlockPos.containing(bounds.maxX - 1, bounds.minY, bounds.maxZ - 1));
22-
stream.add(BlockPos.containing(bounds.minX, bounds.minY, bounds.maxZ - 1));
23-
stream.add(BlockPos.containing(bounds.maxX - 1, bounds.maxY - 1, bounds.minZ));
24-
stream.add(BlockPos.containing(bounds.minX, bounds.maxY - 1, bounds.minZ));
25-
stream.add(BlockPos.containing(bounds.maxX - 1, bounds.minY, bounds.minZ));
26-
stream.add(BlockPos.containing(bounds.minX, bounds.minY, bounds.minZ));
27-
return stream.build();
28-
}
29-
3017
public static AABB getWallBounds(AABB area, Direction wall) {
3118
return getWallBounds(area, wall, 1d);
3219
}

core-api/src/main/java/dev/compactmods/machines/api/util/DirectionalMath.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

core-api/src/main/java/dev/compactmods/machines/api/util/VectorUtils.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

neoforge-main/build.gradle.kts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,22 @@ dependencies {
173173
compileOnly(coreApi)
174174
testCompileOnly(coreApi)
175175
jarJar(coreApi)
176-
177-
compileOnly(libraries.feather)
178-
testImplementation(libraries.feather)
179-
jarJar(libraries.feather) { isTransitive = false }
180176
}
181177

182178
runtimeOnly(neoforged.testframework)
183179
testImplementation(neoforged.testframework)
184180
testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
185181
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
186182

187-
additionalRuntimeClasspath(libraries.feather)
188183
additionalRuntimeClasspath(libraries.jnanoid)
184+
compileOnly(compactmods.feather)
185+
testImplementation(compactmods.feather)
186+
jarJar(compactmods.feather) { isTransitive = false }
187+
188+
compileOnly(compactmods.spatial)
189+
testImplementation(compactmods.spatial)
190+
jarJar(compactmods.spatial) { isTransitive = false }
191+
additionalRuntimeClasspath(compactmods.spatial)
189192
}
190193

191194
tasks.withType<Test> {

0 commit comments

Comments
 (0)