2626import net .minecraft .item .Item ;
2727import net .minecraft .item .ItemStack ;
2828import net .minecraft .item .ItemUsageContext ;
29+ import net .minecraft .server .network .ServerPlayerEntity ;
2930import net .minecraft .util .ActionResult ;
3031import net .minecraft .util .Hand ;
3132import net .minecraft .util .hit .BlockHitResult ;
@@ -61,7 +62,8 @@ private static boolean onBreakBlock(
6162 boolean result =
6263 checkPermissions (player , pos , world , Permissions .BREAK_BLOCKS ) == ActionResult .FAIL ;
6364 if (result ) {
64- InteractionsUtil .warn (player , InteractionsUtilActions .BREAK_BLOCKS );
65+ InteractionsUtil .warn (
66+ (ServerPlayerEntity ) player , InteractionsUtilActions .BREAK_BLOCKS );
6567 }
6668 return !result ;
6769 }
@@ -78,7 +80,7 @@ private static ActionResult onExplodeBlock(
7880 Permissions .BREAK_BLOCKS );
7981 if (result == ActionResult .FAIL ) {
8082 InteractionsUtil .warn (
81- (PlayerEntity ) explosion .getCausingEntity (),
83+ (ServerPlayerEntity ) explosion .getCausingEntity (),
8284 InteractionsUtilActions .BREAK_BLOCKS );
8385 }
8486 return result ;
@@ -117,7 +119,7 @@ private static ActionResult onExplodeDamage(Explosion explosion, Entity entity)
117119 Permissions .ATTACK_ENTITIES );
118120 if (result == ActionResult .FAIL ) {
119121 InteractionsUtil .warn (
120- (PlayerEntity ) explosion .getCausingEntity (),
122+ (ServerPlayerEntity ) explosion .getCausingEntity (),
121123 InteractionsUtilActions .BREAK_BLOCKS );
122124 }
123125 return result ;
@@ -151,16 +153,16 @@ private static ActionResult onUseBlock(
151153
152154 BlockPos hitPos = hitResult .getBlockPos ();
153155 if (checkPermissions (player , hitPos , world , Permissions .USE_BLOCKS ) == ActionResult .FAIL ) {
154- InteractionsUtil .warn (player , InteractionsUtilActions .USE_BLOCKS );
155- InteractionsUtil .sync (player , stack , hand );
156+ InteractionsUtil .warn (( ServerPlayerEntity ) player , InteractionsUtilActions .USE_BLOCKS );
157+ InteractionsUtil .sync (( ServerPlayerEntity ) player , stack , hand );
156158 return ActionResult .FAIL ;
157159 }
158160
159161 BlockPos placePos = hitPos .add (hitResult .getSide ().getVector ());
160162 if (checkPermissions (player , placePos , world , Permissions .USE_BLOCKS )
161163 == ActionResult .FAIL ) {
162- InteractionsUtil .warn (player , InteractionsUtilActions .USE_BLOCKS );
163- InteractionsUtil .sync (player , stack , hand );
164+ InteractionsUtil .warn (( ServerPlayerEntity ) player , InteractionsUtilActions .USE_BLOCKS );
165+ InteractionsUtil .sync (( ServerPlayerEntity ) player , stack , hand );
164166 return ActionResult .FAIL ;
165167 }
166168
@@ -174,8 +176,12 @@ private static ActionResult onPlaceBlock(ItemUsageContext context) {
174176 context .getWorld (),
175177 Permissions .PLACE_BLOCKS )
176178 == ActionResult .FAIL ) {
177- InteractionsUtil .warn (context .getPlayer (), InteractionsUtilActions .PLACE_BLOCKS );
178- InteractionsUtil .sync (context .getPlayer (), context .getStack (), context .getHand ());
179+ InteractionsUtil .warn (
180+ (ServerPlayerEntity ) context .getPlayer (), InteractionsUtilActions .PLACE_BLOCKS );
181+ InteractionsUtil .sync (
182+ (ServerPlayerEntity ) context .getPlayer (),
183+ context .getStack (),
184+ context .getHand ());
179185 return ActionResult .FAIL ;
180186 }
181187
@@ -189,8 +195,11 @@ private static ActionResult onUseBucket(PlayerEntity player, World world, Hand h
189195 ActionResult playerResult =
190196 checkPermissions (player , player .getBlockPos (), world , Permissions .PLACE_BLOCKS );
191197 if (playerResult == ActionResult .FAIL ) {
192- InteractionsUtil .warn (player , InteractionsUtilActions .PLACE_OR_PICKUP_LIQUIDS );
193- InteractionsUtil .sync (player , player .getStackInHand (hand ), hand );
198+ InteractionsUtil .warn (
199+ (ServerPlayerEntity ) player ,
200+ InteractionsUtilActions .PLACE_OR_PICKUP_LIQUIDS );
201+ InteractionsUtil .sync (
202+ (ServerPlayerEntity ) player , player .getStackInHand (hand ), hand );
194203 return ActionResult .FAIL ;
195204 }
196205
@@ -206,16 +215,22 @@ private static ActionResult onUseBucket(PlayerEntity player, World world, Hand h
206215 BlockPos raycastPos = raycastResult .getBlockPos ();
207216 if (checkPermissions (player , raycastPos , world , Permissions .PLACE_BLOCKS )
208217 == ActionResult .FAIL ) {
209- InteractionsUtil .warn (player , InteractionsUtilActions .PLACE_OR_PICKUP_LIQUIDS );
210- InteractionsUtil .sync (player , player .getStackInHand (hand ), hand );
218+ InteractionsUtil .warn (
219+ (ServerPlayerEntity ) player ,
220+ InteractionsUtilActions .PLACE_OR_PICKUP_LIQUIDS );
221+ InteractionsUtil .sync (
222+ (ServerPlayerEntity ) player , player .getStackInHand (hand ), hand );
211223 return ActionResult .FAIL ;
212224 }
213225
214226 BlockPos placePos = raycastPos .add (raycastResult .getSide ().getVector ());
215227 if (checkPermissions (player , placePos , world , Permissions .PLACE_BLOCKS )
216228 == ActionResult .FAIL ) {
217- InteractionsUtil .warn (player , InteractionsUtilActions .PLACE_OR_PICKUP_LIQUIDS );
218- InteractionsUtil .sync (player , player .getStackInHand (hand ), hand );
229+ InteractionsUtil .warn (
230+ (ServerPlayerEntity ) player ,
231+ InteractionsUtilActions .PLACE_OR_PICKUP_LIQUIDS );
232+ InteractionsUtil .sync (
233+ (ServerPlayerEntity ) player , player .getStackInHand (hand ), hand );
219234 return ActionResult .FAIL ;
220235 }
221236 }
@@ -230,7 +245,8 @@ private static ActionResult onAttackEntity(
230245 && checkPermissions (
231246 player , entity .getBlockPos (), world , Permissions .ATTACK_ENTITIES )
232247 == ActionResult .FAIL ) {
233- InteractionsUtil .warn (player , InteractionsUtilActions .ATTACK_ENTITIES );
248+ InteractionsUtil .warn (
249+ (ServerPlayerEntity ) player , InteractionsUtilActions .ATTACK_ENTITIES );
234250 return ActionResult .FAIL ;
235251 }
236252
@@ -246,7 +262,8 @@ private static ActionResult onUseEntity(PlayerEntity player, Entity entity, Worl
246262 }
247263
248264 if (checkPermissions (player , pos , world , Permissions .USE_ENTITIES ) == ActionResult .FAIL ) {
249- InteractionsUtil .warn (player , InteractionsUtilActions .USE_ENTITIES );
265+ InteractionsUtil .warn (
266+ (ServerPlayerEntity ) player , InteractionsUtilActions .USE_ENTITIES );
250267 return ActionResult .FAIL ;
251268 }
252269
@@ -256,7 +273,8 @@ private static ActionResult onUseEntity(PlayerEntity player, Entity entity, Worl
256273 private static ActionResult onUseInventory (PlayerEntity player , BlockPos pos , World world ) {
257274 if (checkPermissions (player , pos , world , Permissions .USE_INVENTORIES )
258275 == ActionResult .FAIL ) {
259- InteractionsUtil .warn (player , InteractionsUtilActions .USE_INVENTORY );
276+ InteractionsUtil .warn (
277+ (ServerPlayerEntity ) player , InteractionsUtilActions .USE_INVENTORY );
260278 return ActionResult .FAIL ;
261279 }
262280
0 commit comments