@@ -65,7 +65,7 @@ public NbtPlacerUtil(NbtCompound storedNbt, HashMap<BlockPos, Pair<BlockState, O
6565 this (storedNbt , positions , entities , lowestPos , sizePos .getX (), sizePos .getY (), sizePos .getZ ());
6666 }
6767
68- public NbtPlacerUtil manipulate (BlockRotation rotation , BlockMirror mirror ) {
68+ public NbtPlacerUtil manipulate (Manipulation manipulation ) {
6969 NbtList paletteList = storedNbt .getList ("palette" , 10 );
7070 HashMap <Integer , BlockState > palette = new HashMap <Integer , BlockState >(paletteList .size ());
7171 List <NbtCompound > paletteCompoundList = paletteList
@@ -79,13 +79,15 @@ public NbtPlacerUtil manipulate(BlockRotation rotation, BlockMirror mirror) {
7979 .put (i ,
8080 NbtHelper
8181 .toBlockState (Registries .BLOCK .asLookup (), paletteCompoundList .get (i ))
82- .rotate (rotation )
83- .mirror (mirror ));
82+ .rotate (manipulation . getRotation () )
83+ .mirror (manipulation . getMirror () ));
8484 }
8585
8686 NbtList sizeList = storedNbt .getList ("size" , 3 );
8787 BlockPos sizeVectorRotated = NbtPlacerUtil
88- .mirror (new BlockPos (sizeList .getInt (0 ), sizeList .getInt (1 ), sizeList .getInt (2 )).rotate (rotation ), mirror );
88+ .mirror (
89+ new BlockPos (sizeList .getInt (0 ), sizeList .getInt (1 ), sizeList .getInt (2 )).rotate (manipulation .getRotation ()),
90+ manipulation .getMirror ());
8991 BlockPos sizeVector = new BlockPos (Math .abs (sizeVectorRotated .getX ()), Math .abs (sizeVectorRotated .getY ()),
9092 Math .abs (sizeVectorRotated .getZ ()));
9193 NbtList positionsList = storedNbt .getList ("blocks" , 10 );
@@ -97,8 +99,10 @@ public NbtPlacerUtil manipulate(BlockRotation rotation, BlockMirror mirror) {
9799 .map (element -> (NbtCompound ) element )
98100 .map ((nbtCompound ) -> Pair
99101 .of (NbtPlacerUtil
100- .mirror (new BlockPos (nbtCompound .getList ("pos" , 3 ).getInt (0 ), nbtCompound .getList ("pos" , 3 ).getInt (1 ),
101- nbtCompound .getList ("pos" , 3 ).getInt (2 )).rotate (rotation ), mirror ),
102+ .mirror (
103+ new BlockPos (nbtCompound .getList ("pos" , 3 ).getInt (0 ), nbtCompound .getList ("pos" , 3 ).getInt (1 ),
104+ nbtCompound .getList ("pos" , 3 ).getInt (2 )).rotate (manipulation .getRotation ()),
105+ manipulation .getMirror ()),
102106 Pair
103107 .of (palette .get (nbtCompound .getInt ("state" )),
104108 nbtCompound .contains ("nbt" , NbtElement .COMPOUND_TYPE )
@@ -112,7 +116,7 @@ public NbtPlacerUtil manipulate(BlockRotation rotation, BlockMirror mirror) {
112116 .forEach (
113117 (pair ) -> positions .put (pair .getFirst ().subtract (positionsPairList .get (0 ).getFirst ()), pair .getSecond ()));
114118 return new NbtPlacerUtil (storedNbt , positions , storedNbt .getList ("entities" , 10 ),
115- transformSize (sizeVector , rotation , mirror ), sizeVector );
119+ transformSize (sizeVector , manipulation . getRotation (), manipulation . getMirror () ), sizeVector );
116120 }
117121
118122 public static NbtPlacerUtil load (Identifier id , ResourceManager manager ) {
@@ -234,23 +238,23 @@ public NbtPlacerUtil generateNbt(ChunkRegion region, Vec3i offset, BlockPos from
234238 return this ;
235239 }
236240
237- public NbtPlacerUtil spawnEntities (ChunkRegion region , BlockPos pos , BlockRotation rotation , BlockMirror mirror ) {
238- return spawnEntities (region , BlockPos .ORIGIN , pos , pos .add (this .sizeX , this .sizeY , this .sizeZ ), rotation , mirror );
241+ public NbtPlacerUtil spawnEntities (ChunkRegion region , BlockPos pos , Manipulation manipulation ) {
242+ return spawnEntities (region , BlockPos .ORIGIN , pos , pos .add (this .sizeX , this .sizeY , this .sizeZ ), manipulation );
239243 }
240244
241245 public NbtPlacerUtil spawnEntities (ChunkRegion region , BlockPos offset , BlockPos from , BlockPos to ,
242- BlockRotation rotation , BlockMirror mirror ) {
243- this .entities .forEach ((nbtElement ) -> spawnEntity (nbtElement , region , offset , from , to , rotation , mirror ));
246+ Manipulation manipulation ) {
247+ this .entities .forEach ((nbtElement ) -> spawnEntity (nbtElement , region , offset , from , to , manipulation ));
244248 return this ;
245249 }
246250
247251 public NbtPlacerUtil spawnEntity (NbtElement nbtElement , ChunkRegion region , BlockPos offset , BlockPos from , BlockPos to ,
248- BlockRotation rotation , BlockMirror mirror ) {
252+ Manipulation manipulation ) {
249253 NbtCompound entityCompound = (NbtCompound ) nbtElement ;
250254 NbtList nbtPos = entityCompound .getList ("pos" , 6 );
251255 Vec3d relativeLocation = mirror (
252- rotate (new Vec3d (nbtPos .getDouble (0 ), nbtPos .getDouble (1 ), nbtPos .getDouble (2 )), rotation ), mirror )
253- .subtract (Vec3d .of (lowestPos ));
256+ rotate (new Vec3d (nbtPos .getDouble (0 ), nbtPos .getDouble (1 ), nbtPos .getDouble (2 )), manipulation . getRotation ()),
257+ manipulation . getMirror ()) .subtract (Vec3d .of (lowestPos ));
254258 Vec3d realPosition = relativeLocation .add (Vec3d .of (from .subtract (offset )));
255259 BlockPos min = offset ;
256260 BlockPos max = to .subtract (from ).add (offset );
@@ -271,14 +275,16 @@ public NbtPlacerUtil spawnEntity(NbtElement nbtElement, ChunkRegion region, Bloc
271275 nbt .put ("Pos" , posList );
272276 NbtList rotationList = new NbtList ();
273277 NbtList entityRotationList = nbt .getList ("Rotation" , 5 );
274- float yawRotation = applyMirror (applyRotation (entityRotationList .getFloat (0 ), rotation ), mirror );
278+ float yawRotation = applyMirror (applyRotation (entityRotationList .getFloat (0 ), manipulation .getRotation ()),
279+ manipulation .getMirror ());
275280 rotationList .add (NbtFloat .of (yawRotation ));
276281 rotationList .add (NbtFloat .of (entityRotationList .getFloat (1 )));
277282 nbt .remove ("Rotation" );
278283 nbt .put ("Rotation" , rotationList );
279284
280285 if (nbt .contains ("facing" )) {
281- Direction dir = mirror (rotation .rotate (Direction .fromHorizontal (nbt .getByte ("facing" ))), mirror );
286+ Direction dir = mirror (manipulation .getRotation ().rotate (Direction .fromHorizontal (nbt .getByte ("facing" ))),
287+ manipulation .getMirror ());
282288 nbt .remove ("facing" );
283289 nbt .putByte ("facing" , (byte ) dir .getHorizontal ());
284290 }
0 commit comments