Skip to content

Commit 758e1f4

Browse files
committed
MDG why
1 parent c43789a commit 758e1f4

File tree

19 files changed

+1841
-1825
lines changed

19 files changed

+1841
-1825
lines changed
Lines changed: 114 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,114 @@
1-
package dev.compactmods.machines.api.room;
2-
3-
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;
7-
import dev.compactmods.machines.api.util.BlockSpaceUtil;
8-
import dev.compactmods.machines.api.util.VectorUtils;
9-
import net.minecraft.core.BlockPos;
10-
import net.minecraft.core.Direction;
11-
import net.minecraft.core.Vec3i;
12-
import net.minecraft.core.registries.BuiltInRegistries;
13-
import net.minecraft.resources.ResourceLocation;
14-
import net.minecraft.server.level.ServerLevel;
15-
import net.minecraft.world.level.LevelAccessor;
16-
import net.minecraft.world.level.block.Block;
17-
import net.minecraft.world.level.block.Blocks;
18-
import net.minecraft.world.level.block.Mirror;
19-
import net.minecraft.world.level.block.Rotation;
20-
import net.minecraft.world.level.block.state.BlockState;
21-
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
22-
import net.minecraft.world.phys.AABB;
23-
import net.minecraft.world.phys.Vec3;
24-
import org.joml.Vector3d;
25-
26-
public class CompactRoomGenerator {
27-
28-
/**
29-
* Generates a wall or platform in a given direction.
30-
* Uses the solid wall block.
31-
*
32-
* @param world
33-
* @param outerBounds
34-
* @param wallDirection
35-
* @since 3.0.0
36-
*/
37-
public static void generateCompactWall(LevelAccessor world, AABB outerBounds, Direction wallDirection, BlockState block) {
38-
AABB wallBounds = BlockSpaceUtil.getWallBounds(outerBounds, wallDirection);
39-
BlockSpaceUtil.blocksInside(wallBounds).forEach(wallBlock -> {
40-
world.setBlock(wallBlock, block, Block.UPDATE_ALL);
41-
});
42-
}
43-
44-
/**
45-
* Generates a machine "internal" structure in a world via a machine size and a central point.
46-
*
47-
* @param world
48-
* @param outerBounds Outer dimensions of the room.
49-
*/
50-
public static void generateRoom(LevelAccessor world, AABB outerBounds) {
51-
final var block = BuiltInRegistries.BLOCK.get(WallConstants.SOLID_WALL);
52-
if (block != null) {
53-
final var solidWall = block.defaultBlockState();
54-
generateRoom(world, outerBounds, solidWall);
55-
}
56-
}
57-
58-
/**
59-
* Generates a machine structure in a world via machine boundaries and a wall block.
60-
*
61-
* @param world
62-
* @param outerBounds Outer dimensions of the room.
63-
* @param block Block to use for walls.
64-
*/
65-
public static void generateRoom(LevelAccessor world, AABB outerBounds, BlockState block) {
66-
67-
// Generate the walls
68-
for (final var dir : Direction.values())
69-
generateCompactWall(world, outerBounds, dir, block);
70-
71-
// Clear out the inside of the room
72-
AABB machineInternal = outerBounds.deflate(1);
73-
BlockSpaceUtil.blocksInside(machineInternal)
74-
.forEach(p -> world.setBlock(p, Blocks.AIR.defaultBlockState(), 7));
75-
}
76-
77-
public static void populateStructure(ServerLevel level, ResourceLocation template, AABB roomInnerBounds, RoomStructureInfo.RoomStructurePlacement placement) {
78-
level.getStructureManager().get(template).ifPresent(tem -> {
79-
80-
Vector3d templateSize = VectorUtils.convert3d(tem.getSize());
81-
82-
if (!AABBHelper.fitsInside(roomInnerBounds, templateSize)) {
83-
// skip: structure too large to place in room
84-
return;
85-
}
86-
87-
var placementSettings = new StructurePlaceSettings()
88-
.setRotation(Rotation.NONE)
89-
.setMirror(Mirror.NONE);
90-
91-
AABB placementBounds = null;
92-
final AABBAligner aligner = AABBAligner.create(roomInnerBounds, templateSize);
93-
switch (placement) {
94-
case CENTERED -> placementBounds = aligner
95-
.center(roomInnerBounds.getCenter())
96-
.align();
97-
98-
case CENTERED_CEILING -> placementBounds = aligner
99-
.boundedDirection(Direction.UP)
100-
.align();
101-
102-
case CENTERED_FLOOR -> placementBounds = aligner
103-
.boundedDirection(Direction.DOWN)
104-
.align();
105-
}
106-
107-
if(placementBounds != null) {
108-
BlockPos placeAt = BlockPos.containing(AABBHelper.minCorner(placementBounds));
109-
tem.placeInWorld(level, placeAt, placeAt, placementSettings, level.random, Block.UPDATE_ALL);
110-
}
111-
});
112-
}
113-
}
1+
package dev.compactmods.machines.api.room;
2+
3+
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;
7+
import dev.compactmods.machines.api.util.BlockSpaceUtil;
8+
import dev.compactmods.machines.api.util.VectorUtils;
9+
import net.minecraft.core.BlockPos;
10+
import net.minecraft.core.Direction;
11+
import net.minecraft.core.Vec3i;
12+
import net.minecraft.core.registries.BuiltInRegistries;
13+
import net.minecraft.resources.ResourceLocation;
14+
import net.minecraft.server.level.ServerLevel;
15+
import net.minecraft.world.level.Level;
16+
import net.minecraft.world.level.LevelAccessor;
17+
import net.minecraft.world.level.block.Block;
18+
import net.minecraft.world.level.block.Blocks;
19+
import net.minecraft.world.level.block.Mirror;
20+
import net.minecraft.world.level.block.Rotation;
21+
import net.minecraft.world.level.block.state.BlockState;
22+
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
23+
import net.minecraft.world.phys.AABB;
24+
import net.minecraft.world.phys.Vec3;
25+
import org.joml.Vector3d;
26+
27+
public class CompactRoomGenerator {
28+
29+
/**
30+
* Generates a wall or platform in a given direction.
31+
* Uses the solid wall block.
32+
*
33+
* @param world
34+
* @param outerBounds
35+
* @param wallDirection
36+
* @since 3.0.0
37+
*/
38+
public static void generateCompactWall(LevelAccessor world, AABB outerBounds, Direction wallDirection, BlockState block) {
39+
AABB wallBounds = BlockSpaceUtil.getWallBounds(outerBounds, wallDirection);
40+
BlockSpaceUtil.blocksInside(wallBounds).forEach(wallBlock -> {
41+
world.setBlock(wallBlock, block, Block.UPDATE_ALL);
42+
});
43+
}
44+
45+
/**
46+
* Generates a machine "internal" structure in a world via a machine size and a central point.
47+
*
48+
* @param world
49+
* @param outerBounds Outer dimensions of the room.
50+
*/
51+
public static void generateRoom(LevelAccessor world, AABB outerBounds) {
52+
final var block = BuiltInRegistries.BLOCK.get(WallConstants.SOLID_WALL);
53+
if (block != null) {
54+
final var solidWall = block.defaultBlockState();
55+
generateRoom(world, outerBounds, solidWall);
56+
}
57+
}
58+
59+
/**
60+
* Generates a machine structure in a world via machine boundaries and a wall block.
61+
*
62+
* @param world
63+
* @param outerBounds Outer dimensions of the room.
64+
* @param block Block to use for walls.
65+
*/
66+
public static void generateRoom(LevelAccessor world, AABB outerBounds, BlockState block) {
67+
68+
// Generate the walls
69+
for (final var dir : Direction.values())
70+
generateCompactWall(world, outerBounds, dir, block);
71+
72+
// Clear out the inside of the room
73+
AABB machineInternal = outerBounds.deflate(1);
74+
BlockSpaceUtil.blocksInside(machineInternal)
75+
.forEach(p -> world.setBlock(p, Blocks.AIR.defaultBlockState(), 7));
76+
}
77+
78+
public static void populateStructure(ServerLevel level, ResourceLocation template, AABB roomInnerBounds, RoomStructureInfo.RoomStructurePlacement placement) {
79+
level.getStructureManager().get(template).ifPresent(tem -> {
80+
81+
Vector3d templateSize = VectorUtils.convert3d(tem.getSize());
82+
83+
if (!AABBHelper.fitsInside(roomInnerBounds, templateSize)) {
84+
// skip: structure too large to place in room
85+
return;
86+
}
87+
88+
var placementSettings = new StructurePlaceSettings()
89+
.setRotation(Rotation.NONE)
90+
.setMirror(Mirror.NONE);
91+
92+
AABB placementBounds = null;
93+
final AABBAligner aligner = AABBAligner.create(roomInnerBounds, templateSize);
94+
switch (placement) {
95+
case CENTERED -> placementBounds = aligner
96+
.center(roomInnerBounds.getCenter())
97+
.align();
98+
99+
case CENTERED_CEILING -> placementBounds = aligner
100+
.boundedDirection(Direction.UP)
101+
.align();
102+
103+
case CENTERED_FLOOR -> placementBounds = aligner
104+
.boundedDirection(Direction.DOWN)
105+
.align();
106+
}
107+
108+
if(placementBounds != null) {
109+
BlockPos placeAt = BlockPos.containing(AABBHelper.minCorner(placementBounds));
110+
tem.placeInWorld(level, placeAt, placeAt, placementSettings, level.random, Block.UPDATE_ALL);
111+
}
112+
});
113+
}
114+
}

gradle/wrapper/gradle-wrapper.jar

-18.2 KB
Binary file not shown.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
44
networkTimeout=10000
5+
validateDistributionUrl=true
56
zipStoreBase=GRADLE_USER_HOME
67
zipStorePath=wrapper/dists

gradlew

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
# Darwin, MinGW, and NonStop.
5656
#
5757
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
58+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5959
# within the Gradle project.
6060
#
6161
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -83,7 +83,8 @@ done
8383
# This is normally unused
8484
# shellcheck disable=SC2034
8585
APP_BASE_NAME=${0##*/}
86-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
86+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
8788

8889
# Use the maximum available, or set MAX_FD != -1 to use that value.
8990
MAX_FD=maximum
@@ -130,26 +131,29 @@ location of your Java installation."
130131
fi
131132
else
132133
JAVACMD=java
133-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134+
if ! command -v java >/dev/null 2>&1
135+
then
136+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134137
135138
Please set the JAVA_HOME variable in your environment to match the
136139
location of your Java installation."
140+
fi
137141
fi
138142

139143
# Increase the maximum file descriptors if we can.
140144
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
141145
case $MAX_FD in #(
142146
max*)
143147
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
144-
# shellcheck disable=SC3045
148+
# shellcheck disable=SC2039,SC3045
145149
MAX_FD=$( ulimit -H -n ) ||
146150
warn "Could not query maximum file descriptor limit"
147151
esac
148152
case $MAX_FD in #(
149153
'' | soft) :;; #(
150154
*)
151155
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
152-
# shellcheck disable=SC3045
156+
# shellcheck disable=SC2039,SC3045
153157
ulimit -n "$MAX_FD" ||
154158
warn "Could not set maximum file descriptor limit to $MAX_FD"
155159
esac
@@ -198,11 +202,11 @@ fi
198202
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
199203
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
200204

201-
# Collect all arguments for the java command;
202-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
203-
# shell script including quotes and variable substitutions, so put them in
204-
# double quotes to make sure that they get re-expanded; and
205-
# * put everything else in single quotes, so that it's not re-expanded.
205+
# Collect all arguments for the java command:
206+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207+
# and any embedded shellness will be escaped.
208+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209+
# treated as '${Hostname}' itself on the command line.
206210

207211
set -- \
208212
"-Dorg.gradle.appname=$APP_BASE_NAME" \

0 commit comments

Comments
 (0)