1
1
package ace .actually .pirates .blocks .entity ;
2
2
3
3
import ace .actually .pirates .blocks .MotionInvokingBlock ;
4
+ import ace .actually .pirates .util .ConfigUtils ;
4
5
import ace .actually .pirates .util .PatternProcessor ;
5
6
import ace .actually .pirates .Pirates ;
6
7
import net .minecraft .block .Block ;
9
10
import net .minecraft .block .entity .BlockEntity ;
10
11
import net .minecraft .nbt .NbtCompound ;
11
12
import net .minecraft .nbt .NbtList ;
13
+ import net .minecraft .registry .tag .BlockTags ;
12
14
import net .minecraft .server .world .ServerWorld ;
13
15
import net .minecraft .util .math .BlockPos ;
14
16
import net .minecraft .util .math .ChunkPos ;
15
17
import net .minecraft .world .World ;
16
18
import org .valkyrienskies .core .api .ships .LoadedServerShip ;
17
19
import org .valkyrienskies .core .util .datastructures .DenseBlockPosSet ;
18
20
import org .valkyrienskies .eureka .block .ShipHelmBlock ;
21
+ import org .valkyrienskies .eureka .util .ShipAssembler ;
19
22
import org .valkyrienskies .mod .api .SeatedControllingPlayer ;
20
23
import org .valkyrienskies .mod .common .VSGameUtilsKt ;
21
24
import org .valkyrienskies .mod .common .ValkyrienSkiesMod ;
@@ -31,6 +34,8 @@ public class MotionInvokingBlockEntity extends BlockEntity {
31
34
NbtList instructions = new NbtList ();
32
35
long nextInstruction = 0 ;
33
36
37
+ private static int maxShipSizeConfig = -5 ;
38
+
34
39
public MotionInvokingBlockEntity (BlockPos pos , BlockState state ) {
35
40
super (Pirates .MOTION_INVOKING_BLOCK_ENTITY , pos , state );
36
41
}
@@ -89,8 +94,19 @@ public static void tick(World world, BlockPos pos, BlockState state, MotionInvok
89
94
}
90
95
91
96
private void buildShipRec (ServerWorld world , BlockPos pos ) {
92
- //ShipAssembler.INSTANCE.collectBlocks(world, pos, a -> !a.isAir() && !a.isOf(Blocks.WATER) && !a.isOf(Blocks.KELP) && !a.isOf(Blocks.KELP_PLANT) && !a.isOf(Blocks.SAND) && !a.isIn(BlockTags.ICE) && !a.isOf(Blocks.STONE));
93
- collectBlocks (world ,pos );
97
+ if (maxShipSizeConfig ==-5 )
98
+ {
99
+ maxShipSizeConfig = Integer .parseInt (ConfigUtils .config .getOrDefault ("max-ship-blocks" ,"5000" ));
100
+ }
101
+ if (maxShipSizeConfig ==-1 )
102
+ {
103
+ ShipAssembler .INSTANCE .collectBlocks (world , pos , a -> !a .isAir () && !a .isOf (Blocks .WATER ) && !a .isOf (Blocks .KELP ) && !a .isOf (Blocks .KELP_PLANT ) && !a .isOf (Blocks .SAND ) && !a .isIn (BlockTags .ICE ) && !a .isOf (Blocks .STONE ));
104
+ }
105
+ else
106
+ {
107
+ collectBlocks (world ,pos );
108
+ }
109
+
94
110
}
95
111
96
112
@ Override
@@ -133,7 +149,7 @@ private void utiliseInternalPattern(SeatedControllingPlayer seatedControllingPla
133
149
public void collectBlocks (ServerWorld world , BlockPos center )
134
150
{
135
151
sortDense (world ,center );
136
- if (SET .size ()<5000 )
152
+ if (SET .size ()< maxShipSizeConfig )
137
153
{
138
154
ShipAssemblyKt .createNewShipWithBlocks (center , SET , world );
139
155
}
@@ -143,29 +159,32 @@ public void collectBlocks(ServerWorld world, BlockPos center)
143
159
}
144
160
}
145
161
146
- private static final List <Block > a = List .of (Blocks .SAND ,Blocks .STONE ,Blocks .ICE ,Blocks .PACKED_ICE ,Blocks .BLUE_ICE ,Blocks .KELP ,Blocks .KELP_PLANT ,Blocks .AIR ,Blocks .WATER );
162
+ private static final List <Block > a = List .of (Blocks .SAND ,Blocks .GRAVEL , Blocks . STONE ,Blocks .ICE ,Blocks .PACKED_ICE ,Blocks .BLUE_ICE ,Blocks .KELP ,Blocks .KELP_PLANT ,Blocks .AIR , Blocks . CAVE_AIR , Blocks . VOID_AIR ,Blocks .WATER );
147
163
private static final DenseBlockPosSet SET = new DenseBlockPosSet ();
148
164
149
165
public void sortDense (ServerWorld world , BlockPos here )
150
166
{
151
167
for (int i = -2 ; i < 3 ; i ++) {
152
168
for (int j = -2 ; j < 3 ; j ++) {
153
169
for (int k = -2 ; k < 3 ; k ++) {
154
- //this means that we could hit 5000 in this loop, this is considered a false-start
155
- if (SET .getSize ()<5000 )
170
+ //this means that we could hit maxShipSize in this loop, this is considered a false-start
171
+ if (SET .getSize ()< maxShipSizeConfig )
156
172
{
157
173
BlockPos o = here .add (i ,j ,k );
158
174
if (!SET .contains (o .getX (),o .getY (),o .getZ ()))
159
175
{
160
176
if (!a .contains (world .getBlockState (o ).getBlock ()))
161
177
{
162
178
SET .add (o .getX (),o .getY (),o .getZ ());
163
- //System.out.println(SET.size());
164
179
sortDense (world ,o );
165
180
}
166
181
167
182
}
168
183
}
184
+ else
185
+ {
186
+ Pirates .LOGGER .info ("A ship tried to spawn over {} blocks! Disarming..." , maxShipSizeConfig );
187
+ }
169
188
170
189
}
171
190
}
0 commit comments