1
1
package com .kkllffaa .meteor_litematica_printer ;
2
2
3
- import static meteordevelopment .meteorclient .MeteorClient .mc ;
4
- import static meteordevelopment .meteorclient .utils .world .BlockUtils .canPlace ;
5
-
6
- import baritone .api .utils .BetterBlockPos ;
7
- import baritone .api .utils .RayTraceUtils ;
8
- import baritone .api .utils .Rotation ;
9
- import baritone .api .utils .RotationUtils ;
10
3
import meteordevelopment .meteorclient .utils .player .Rotations ;
11
4
import meteordevelopment .meteorclient .utils .world .BlockUtils ;
12
- import net .minecraft .block .AmethystClusterBlock ;
13
- import net .minecraft .block .AnvilBlock ;
14
- import net .minecraft .block .BellBlock ;
15
- import net .minecraft .block .Block ;
16
- import net .minecraft .block .BlockState ;
17
- import net .minecraft .block .Blocks ;
18
- import net .minecraft .block .ButtonBlock ;
19
- import net .minecraft .block .ChainBlock ;
20
- import net .minecraft .block .EndRodBlock ;
21
- import net .minecraft .block .GrindstoneBlock ;
22
- import net .minecraft .block .HopperBlock ;
23
- import net .minecraft .block .LightningRodBlock ;
24
- import net .minecraft .block .ObserverBlock ;
25
- import net .minecraft .block .PistonBlock ;
26
- import net .minecraft .block .PointedDripstoneBlock ;
27
- import net .minecraft .block .ScaffoldingBlock ;
28
- import net .minecraft .block .ShulkerBoxBlock ;
29
- import net .minecraft .block .SlabBlock ;
30
- import net .minecraft .block .StainedGlassBlock ;
31
- import net .minecraft .block .StairsBlock ;
32
- import net .minecraft .block .TrapdoorBlock ;
5
+ import net .minecraft .block .*;
33
6
import net .minecraft .block .enums .BlockHalf ;
34
7
import net .minecraft .block .enums .SlabType ;
35
- import net .minecraft .item .ItemStack ;
36
- import net .minecraft .nbt .NbtCompound ;
37
8
import net .minecraft .network .packet .c2s .play .HandSwingC2SPacket ;
38
9
import net .minecraft .state .property .Properties ;
39
- import net .minecraft .state .property .Property ;
40
10
import net .minecraft .util .ActionResult ;
41
11
import net .minecraft .util .Hand ;
42
12
import net .minecraft .util .hit .BlockHitResult ;
43
13
import net .minecraft .util .hit .HitResult ;
44
14
import net .minecraft .util .math .BlockPos ;
45
15
import net .minecraft .util .math .Box ;
46
16
import net .minecraft .util .math .Direction ;
47
- import net .minecraft .util .math .Vec3d ;
48
17
import net .minecraft .util .math .Direction .Axis ;
18
+ import net .minecraft .util .math .Vec3d ;
49
19
import net .minecraft .util .shape .VoxelShape ;
50
20
import net .minecraft .world .RaycastContext ;
51
21
import net .minecraft .world .RaycastContext .FluidHandling ;
52
22
import net .minecraft .world .RaycastContext .ShapeType ;
53
23
24
+ import static meteordevelopment .meteorclient .MeteorClient .mc ;
25
+ import static meteordevelopment .meteorclient .utils .world .BlockUtils .canPlace ;
26
+
27
+ //import baritone.api.utils.BetterBlockPos;
28
+ //import baritone.api.utils.RayTraceUtils;
29
+ //import baritone.api.utils.Rotation;
30
+ //import baritone.api.utils.RotationUtils;
31
+
54
32
public class MyUtils {
55
-
33
+
56
34
public static boolean place (BlockPos blockPos , Direction direction , SlabType slabType , BlockHalf blockHalf , Direction blockHorizontalOrientation , Axis wantedAxies , boolean airPlace , boolean swingHand , boolean rotate , boolean clientSide , int range ) {
57
35
if (mc .player == null ) return false ;
58
36
if (!canPlace (blockPos )) return false ;
@@ -76,8 +54,8 @@ public static boolean place(BlockPos blockPos, Direction direction, SlabType sla
76
54
Direction s = direction ;
77
55
78
56
if (rotate ) {
79
- BetterBlockPos placeAgainstPos = new BetterBlockPos (neighbour .getX (), neighbour .getY (), neighbour .getZ ());
80
- VoxelShape collisionShape = mc .world .getBlockState (placeAgainstPos ).getCollisionShape (mc .world , placeAgainstPos );
57
+ // BetterBlockPos placeAgainstPos = new BetterBlockPos(neighbour.getX(), neighbour.getY(), neighbour.getZ());
58
+ VoxelShape collisionShape = mc .world .getBlockState (neighbour ).getCollisionShape (mc .world , neighbour );
81
59
82
60
if (collisionShape .isEmpty ()) {
83
61
Rotations .rotate (Rotations .getYaw (hitPos ), Rotations .getPitch (hitPos ), 50 , clientSide ,
@@ -93,30 +71,30 @@ public static boolean place(BlockPos blockPos, Direction direction, SlabType sla
93
71
for (double x = 0.1 ; x < 0.9 ; x +=0.2 )
94
72
for (Vec3d placementMultiplier : aabbSideMultipliers (direction .getOpposite ())) {
95
73
96
- double placeX = placeAgainstPos . x + aabb .minX * x + aabb .maxX * (1 - x );
74
+ double placeX = neighbour . getX () + aabb .minX * x + aabb .maxX * (1 - x );
97
75
if ((slabType != null && slabType != SlabType .DOUBLE || blockHalf != null && direction != Direction .UP && direction != Direction .DOWN ) && !mc .player .isCreative ()) {
98
76
if (slabType == SlabType .BOTTOM || blockHalf == BlockHalf .BOTTOM ) {
99
77
if (placementMultiplier .y <= 0.5 ) continue ;
100
78
} else {
101
79
if (placementMultiplier .y > 0.5 ) continue ;
102
80
}
103
81
}
104
- double placeY = placeAgainstPos . y + aabb .minY * placementMultiplier .y + aabb .maxY * (1 - placementMultiplier .y );
105
- double placeZ = placeAgainstPos . z + aabb .minZ * z + aabb .maxZ * (1 - z );
82
+ double placeY = neighbour . getY () + aabb .minY * placementMultiplier .y + aabb .maxY * (1 - placementMultiplier .y );
83
+ double placeZ = neighbour . getZ () + aabb .minZ * z + aabb .maxZ * (1 - z );
106
84
107
85
Vec3d testHitPos = new Vec3d (placeX , placeY , placeZ );
108
86
Vec3d playerHead = new Vec3d (mc .player .getX (), mc .player .getEyeY (), mc .player .getZ ());
109
87
110
- Rotation rot = RotationUtils .calcRotationFromVec3d (playerHead , testHitPos , new Rotation (mc .player .getYaw (), mc .player .getPitch ()));
88
+ Rotation rot = RotationStuff .calcRotationFromVec3d (playerHead , testHitPos , new Rotation (mc .player .getYaw (), mc .player .getPitch ()));
111
89
Direction testHorizontalDirection = getHorizontalDirectionFromYaw (rot .normalize ().getYaw ());
112
90
if (blockHorizontalOrientation != null
113
91
&& ( testHorizontalDirection .getAxis () != blockHorizontalOrientation .getAxis ())) continue ;
114
- HitResult res = RayTraceUtils .rayTraceTowards (mc .player , rot , range , false );
92
+ HitResult res = RotationStuff .rayTraceTowards (mc .player , rot , range );
115
93
BlockHitResult blockHitRes = ((BlockHitResult ) res );
116
94
if (
117
95
res == null ||
118
96
res .getType () != HitResult .Type .BLOCK ||
119
- !blockHitRes .getBlockPos ().equals (placeAgainstPos ) ||
97
+ !blockHitRes .getBlockPos ().equals (neighbour ) ||
120
98
blockHitRes .getSide () != direction
121
99
) continue ;
122
100
@@ -135,6 +113,7 @@ public static boolean place(BlockPos blockPos, Direction direction, SlabType sla
135
113
return true ;
136
114
}
137
115
116
+
138
117
private static void place (BlockHitResult blockHitResult , boolean swing ) {
139
118
if (mc .player == null || mc .interactionManager == null || mc .getNetworkHandler () == null ) return ;
140
119
boolean wasSneaking = mc .player .input .sneaking ;
@@ -302,11 +281,11 @@ public static boolean isPlayerOrientationDesired(Block block, Direction blockHor
302
281
303
282
);
304
283
}
305
-
284
+
306
285
public static Direction getVisiblePlaceSide (BlockPos placeAt , BlockState placeAtState , SlabType slabType , BlockHalf blockHalf , Direction blockHorizontalOrientation , Axis wantedAxies , int range , Direction requiredDir ) {
307
286
if (mc .world == null ) return null ;
308
287
for (Direction against : Direction .values ()) {
309
- BetterBlockPos placeAgainstPos = new BetterBlockPos (placeAt .getX (), placeAt .getY (), placeAt .getZ ()).relative (against );
288
+ // BetterBlockPos placeAgainstPos = new BetterBlockPos(placeAt.getX(), placeAt.getY(), placeAt.getZ()).relative(against);
310
289
// BlockState placeAgainstState = mc.world.getBlockState(placeAgainstPos);
311
290
312
291
if (wantedAxies != null && against .getAxis () != wantedAxies || blockHalf != null && (against == Direction .UP && blockHalf == BlockHalf .BOTTOM || against == Direction .DOWN && blockHalf == BlockHalf .TOP ))
@@ -324,41 +303,41 @@ public static Direction getVisiblePlaceSide(BlockPos placeAt, BlockState placeAt
324
303
325
304
if (!canPlaceAgainst (
326
305
placeAtState ,
327
- mc .world .getBlockState (placeAgainstPos ),
306
+ mc .world .getBlockState (placeAt ),
328
307
against
329
- ) || BlockUtils .isClickable (mc .world .getBlockState (placeAgainstPos ).getBlock ()))
308
+ ) || BlockUtils .isClickable (mc .world .getBlockState (placeAt ).getBlock ()))
330
309
continue ;
331
- Box aabb = mc .world .getBlockState (placeAgainstPos ).getCollisionShape (mc .world , placeAgainstPos ).getBoundingBox ();
310
+ Box aabb = mc .world .getBlockState (placeAt ).getCollisionShape (mc .world , placeAt ).getBoundingBox ();
332
311
333
312
for (double z = 0.1 ; z < 0.9 ; z +=0.2 )
334
313
for (double x = 0.1 ; x < 0.9 ; x +=0.2 )
335
314
for (Vec3d placementMultiplier : aabbSideMultipliers (against )) {
336
- double placeX = placeAgainstPos . x + aabb .minX * x + aabb .maxX * (1 - x );
315
+ double placeX = placeAt . getX () + aabb .minX * x + aabb .maxX * (1 - x );
337
316
if ((slabType != null && slabType != SlabType .DOUBLE || blockHalf != null && against != Direction .DOWN && against != Direction .UP ) && !mc .player .isCreative ()) {
338
317
if (slabType == SlabType .BOTTOM || blockHalf == BlockHalf .BOTTOM ) {
339
318
if (placementMultiplier .y <= 0.5 ) continue ;
340
319
} else {
341
320
if (placementMultiplier .y > 0.5 ) continue ;
342
321
}
343
322
}
344
- double placeY = placeAgainstPos . y + aabb .minY * placementMultiplier .y + aabb .maxY * (1 - placementMultiplier .y );
345
- double placeZ = placeAgainstPos . z + aabb .minZ * z + aabb .maxZ * (1 - z );
323
+ double placeY = placeAt . getY () + aabb .minY * placementMultiplier .y + aabb .maxY * (1 - placementMultiplier .y );
324
+ double placeZ = placeAt . getZ () + aabb .minZ * z + aabb .maxZ * (1 - z );
346
325
347
326
Vec3d hitPos = new Vec3d (placeX , placeY , placeZ );
348
327
Vec3d playerHead = new Vec3d (mc .player .getX (), mc .player .getEyeY (), mc .player .getZ ());
349
- Rotation rot = RotationUtils .calcRotationFromVec3d (playerHead , hitPos , new Rotation (mc .player .getYaw (), mc .player .getPitch ()));
328
+ Rotation rot = RotationStuff .calcRotationFromVec3d (playerHead , hitPos , new Rotation (mc .player .getYaw (), mc .player .getPitch ()));
350
329
351
330
Direction testHorizontalDirection = getHorizontalDirectionFromYaw (rot .normalize ().getYaw ());
352
331
if (placeAtState .getBlock () instanceof TrapdoorBlock && !(against != Direction .DOWN && against != Direction .UP ) && !isPlayerOrientationDesired (placeAtState .getBlock (), blockHorizontalOrientation , testHorizontalDirection )
353
332
|| !(placeAtState .getBlock () instanceof TrapdoorBlock ) && !isPlayerOrientationDesired (placeAtState .getBlock (), blockHorizontalOrientation , testHorizontalDirection )
354
333
) continue ;
355
- HitResult res = RayTraceUtils .rayTraceTowards (mc .player , rot , range , false );
334
+ HitResult res = RotationStuff .rayTraceTowards (mc .player , rot , range );
356
335
BlockHitResult blockHitRes = ((BlockHitResult ) res );
357
336
358
337
if (
359
338
res == null
360
339
|| res .getType () != HitResult .Type .BLOCK
361
- || !blockHitRes .getBlockPos ().equals (placeAgainstPos )
340
+ || !blockHitRes .getBlockPos ().equals (placeAt )
362
341
|| blockHitRes .getSide () != against .getOpposite ()
363
342
) continue ;
364
343
@@ -403,7 +382,7 @@ public static Direction getPlaceSide(BlockPos blockPos, BlockState placeAtState,
403
382
404
383
Vec3d hitPos = new Vec3d (neighbor .getX (), neighbor .getY (), neighbor .getZ ());
405
384
Vec3d playerHead = new Vec3d (mc .player .getX (), mc .player .getEyeY (), mc .player .getZ ());
406
- Rotation rot = RotationUtils .calcRotationFromVec3d (playerHead , hitPos , new Rotation (mc .player .getYaw (), mc .player .getPitch ()));
385
+ Rotation rot = RotationStuff .calcRotationFromVec3d (playerHead , hitPos , new Rotation (mc .player .getYaw (), mc .player .getPitch ()));
407
386
408
387
Direction testHorizontalDirection = getHorizontalDirectionFromYaw (rot .normalize ().getYaw ());
409
388
@@ -417,7 +396,9 @@ public static Direction getPlaceSide(BlockPos blockPos, BlockState placeAtState,
417
396
return null ;
418
397
}
419
398
399
+ /*
420
400
public static NbtCompound getNbtFromBlockState (ItemStack itemStack, BlockState state) {
401
+ //NbtCompound nbt = itemStack.getOrCreateNbt();
421
402
NbtCompound nbt = itemStack.getOrCreateNbt();
422
403
NbtCompound subNbt = new NbtCompound();
423
404
for (Property<?> property : state.getProperties()) {
@@ -427,7 +408,7 @@ public static NbtCompound getNbtFromBlockState (ItemStack itemStack, BlockState
427
408
428
409
return nbt;
429
410
}
430
-
411
+ */
431
412
private static Vec3d [] aabbSideMultipliers (Direction side ) {
432
413
switch (side ) {
433
414
case UP :
0 commit comments