33import java .util .*;
44
55import net .minecraft .block .Block ;
6- import net .minecraft .block .material .Material ;
76import net .minecraft .entity .player .EntityPlayer ;
87import net .minecraft .entity .player .InventoryPlayer ;
98import net .minecraft .item .*;
109import net .minecraft .launchwrapper .Launch ;
1110import net .minecraft .nbt .NBTTagCompound ;
1211import net .minecraft .stats .StatList ;
13- import net .minecraft .util .MathHelper ;
14- import net .minecraft .util .MovingObjectPosition ;
1512import net .minecraft .util .StatCollector ;
1613import net .minecraft .world .World ;
1714import net .minecraft .world .biome .BiomeGenBase ;
2118import net .minecraftforge .event .entity .player .PlayerDestroyItemEvent ;
2219import net .minecraftforge .fluids .*;
2320import net .minecraftforge .oredict .OreDictionary ;
24- import net .pufferlab .primal .blocks .* ;
21+ import net .pufferlab .primal .blocks .BlockContainerPrimal ;
2522import net .pufferlab .primal .utils .*;
2623import net .pufferlab .primal .world .GlobalTickingData ;
2724
@@ -113,157 +110,6 @@ public static Random getSeededRandom(Random random, int x, int y, int z) {
113110 return random ;
114111 }
115112
116- public static int getBlockX (int side , int x ) {
117- if (side == 4 ) {
118- x --;
119- }
120- if (side == 5 ) {
121- x ++;
122- }
123- return x ;
124- }
125-
126- public static int getBlockY (int side , int y ) {
127- if (side == 0 ) {
128- y --;
129- }
130- if (side == 1 ) {
131- y ++;
132- }
133- return y ;
134- }
135-
136- public static int getBlockZ (int side , int z ) {
137- if (side == 2 ) {
138- z --;
139- }
140- if (side == 3 ) {
141- z ++;
142- }
143- return z ;
144- }
145-
146- public static boolean hasSolidWallsTop (World world , int x , int y , int z ) {
147- for (ForgeDirection dir : ForgeDirection .VALID_DIRECTIONS ) {
148- Block block = world .getBlock (x + dir .offsetX , y + dir .offsetY , z + dir .offsetZ );
149- boolean isSolid = block
150- .isSideSolid (world , x + dir .offsetX , y + dir .offsetY , z + dir .offsetZ , dir .getOpposite ())
151- || (block instanceof BlockPile )
152- || (block .getMaterial () == Material .fire );
153- if (!isSolid ) {
154- return false ;
155- }
156-
157- }
158- return true ;
159- }
160-
161- public static boolean hasSolidWalls (World world , int x , int y , int z ) {
162- for (ForgeDirection dir : ItemUtils .sideDirections ) {
163- Block block = world .getBlock (x + dir .offsetX , y + dir .offsetY , z + dir .offsetZ );
164- if (!block .isSideSolid (world , x + dir .offsetX , y + dir .offsetY , z + dir .offsetZ , dir .getOpposite ())) {
165- return false ;
166- }
167- }
168- return true ;
169- }
170-
171- public static Block getBlockDirection (World world , int x , int y , int z , ForgeDirection ... directions ) {
172- int offsetX = x ;
173- int offsetY = y ;
174- int offsetZ = z ;
175- for (ForgeDirection direction : directions ) {
176- offsetX += direction .offsetX ;
177- offsetY += direction .offsetY ;
178- offsetZ += direction .offsetZ ;
179- }
180- return world .getBlock (offsetX , offsetY , offsetZ );
181- }
182-
183- public static boolean setBlockDirection (World world , int x , int y , int z , Block block , int meta ,
184- ForgeDirection ... directions ) {
185- int offsetX = x ;
186- int offsetY = y ;
187- int offsetZ = z ;
188- for (ForgeDirection direction : directions ) {
189- offsetX += direction .offsetX ;
190- offsetY += direction .offsetY ;
191- offsetZ += direction .offsetZ ;
192- }
193- return world .setBlock (offsetX , offsetY , offsetZ , block , meta , 2 );
194- }
195-
196- public static ForgeDirection getDirectionFromFacing (int facingMeta ) {
197- return switch (facingMeta ) {
198- case 1 -> ForgeDirection .SOUTH ;
199- case 2 -> ForgeDirection .EAST ;
200- case 3 -> ForgeDirection .NORTH ;
201- case 4 -> ForgeDirection .WEST ;
202- default -> ForgeDirection .UNKNOWN ;
203- };
204- }
205-
206- public static int getFacingMeta (int side , int axis ) {
207- if (axis == 0 ) {
208- return switch (side ) {
209- case 3 -> 1 ;
210- case 4 -> 4 ;
211- case 2 -> 3 ;
212- case 5 -> 2 ;
213- default -> 0 ;
214- };
215- }
216- if (axis == 1 ) {
217- return switch (side ) {
218- case 0 -> 1 ;
219- case 4 -> 4 ;
220- case 1 -> 3 ;
221- case 5 -> 2 ;
222- default -> 0 ;
223- };
224- }
225- if (axis == 2 ) {
226- return switch (side ) {
227- case 3 -> 1 ;
228- case 1 -> 4 ;
229- case 2 -> 3 ;
230- case 0 -> 2 ;
231- default -> 0 ;
232- };
233- }
234- return 0 ;
235- }
236-
237- public static int getSimpleAxisFromFacing (int facingMeta ) {
238- return switch (facingMeta ) {
239- case 1 , 3 -> 1 ;
240- case 2 , 4 -> 2 ;
241- default -> 0 ;
242- };
243- }
244-
245- public static int getAxis (int side ) {
246- if (side == 0 || side == 1 ) {
247- return 0 ;
248- } else if (side == 2 || side == 3 ) {
249- return 1 ;
250- } else if (side == 4 || side == 5 ) {
251- return 2 ;
252- }
253- return 0 ;
254- }
255-
256- public static boolean isSidePositive (int side ) {
257- if (side == 1 || side == 3 || side == 5 ) {
258- return true ;
259- }
260- return false ;
261- }
262-
263- public static boolean isSimpleAxisConnected (int facingMeta , int facingMeta2 ) {
264- return getSimpleAxisFromFacing (facingMeta ) == getSimpleAxisFromFacing (facingMeta2 );
265- }
266-
267113 public static boolean equalsStack (ItemStack wild , ItemStack check ) {
268114 if (wild == null || check == null ) {
269115 return check == wild ;
@@ -294,37 +140,16 @@ public static boolean equalsStack(ItemStack check, FluidStack wild) {
294140 return wild .getFluid () == stack .getFluid ();
295141 }
296142
297- public static MovingObjectPosition getMovingObjectPositionFromPlayer (World worldIn , EntityPlayer playerIn ,
298- boolean useLiquids ) {
299- return ItemDummy .instance .getMovingObjectPositionFromPlayerPublic (worldIn , playerIn , useLiquids );
300- }
301-
302- public static int getDirectionXZYaw (int yaw ) {
303- if (yaw == 0 ) {
304- return 1 ;
305- } else if (yaw == 1 ) {
306- return 4 ;
307- } else if (yaw == 2 ) {
308- return 3 ;
309- } else if (yaw == 3 ) {
310- return 2 ;
311- }
312-
313- return 0 ;
314- }
315-
316- public static int getMetaYaw (float rotationYaw ) {
317- int yaw = MathHelper .floor_double ((double ) (rotationYaw * 4.0F / 360.0F ) + 0.5D ) & 3 ;
318- return getDirectionXZYaw (yaw );
319- }
320-
321143 public static void place (ItemStack stack , World world , int x , int y , int z , Block toPlace , int metadata ,
322144 EntityPlayer player ) {
323145 if (world .isAirBlock (x , y , z ) && world .isSideSolid (x , y - 1 , z , ForgeDirection .UP )) {
324146 if (world .checkNoEntityCollision (toPlace .getCollisionBoundingBoxFromPool (world , x , y , z ))
325147 && world .setBlock (x , y , z , toPlace , metadata , 3 )) {
326148 world .setBlock (x , y , z , toPlace , metadata , 2 );
327149 toPlace .onBlockPlacedBy (world , x , y , z , player , stack );
150+ if (toPlace instanceof BlockContainerPrimal block2 ) {
151+ block2 .onBlockSidePlacedBy (world , x , y , z , player , stack , 0 );
152+ }
328153 stack .stackSize -= 1 ;
329154 playSound (world , x , y , z , toPlace );
330155 player .swingItem ();
@@ -339,6 +164,9 @@ public static void placeNoConsume(ItemStack stack, World world, int x, int y, in
339164 && world .setBlock (x , y , z , toPlace , metadata , 3 )) {
340165 world .setBlock (x , y , z , toPlace , metadata , 2 );
341166 toPlace .onBlockPlacedBy (world , x , y , z , player , stack );
167+ if (toPlace instanceof BlockContainerPrimal block2 ) {
168+ block2 .onBlockSidePlacedBy (world , x , y , z , player , stack , 0 );
169+ }
342170 playSound (world , x , y , z , toPlace );
343171 player .swingItem ();
344172 }
@@ -352,6 +180,9 @@ public static void placeSilent(ItemStack stack, World world, int x, int y, int z
352180 && world .setBlock (x , y , z , toPlace , metadata , 3 )) {
353181 world .setBlock (x , y , z , toPlace , metadata , 2 );
354182 toPlace .onBlockPlacedBy (world , x , y , z , player , stack );
183+ if (toPlace instanceof BlockContainerPrimal block2 ) {
184+ block2 .onBlockSidePlacedBy (world , x , y , z , player , stack , 0 );
185+ }
355186 player .swingItem ();
356187 }
357188 }
0 commit comments