From b047822cbbf51ae5e04944103fcfe6f68f56c267 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Thu, 19 May 2022 12:06:54 +0200 Subject: [PATCH] Change wrong exception type --- src/main/java/com/yes/yes/behaviours/OfferBehaviour.java | 6 +++--- src/main/java/com/yes/yes/behaviours/PlaceBehaviour.java | 2 +- src/main/java/com/yes/yes/behaviours/ReceiveBehaviour.java | 4 ++-- src/main/java/com/yes/yes/utils/BlockContainer.java | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/yes/yes/behaviours/OfferBehaviour.java b/src/main/java/com/yes/yes/behaviours/OfferBehaviour.java index 1f431e1..1164725 100644 --- a/src/main/java/com/yes/yes/behaviours/OfferBehaviour.java +++ b/src/main/java/com/yes/yes/behaviours/OfferBehaviour.java @@ -25,7 +25,7 @@ public class OfferBehaviour extends Component { if (blockContainer.getBlockRelative(direction, parent.getRotation()) == entity) { this.receiver = entity; } - } catch (IllegalAccessException e) { + } catch (IllegalArgumentException e) { e.printStackTrace(); } } @@ -35,7 +35,7 @@ public class OfferBehaviour extends Component { if (blockContainer.getBlockRelative(direction, parent.getRotation()) == entity) { this.parent.setData(dataKey, null); } - } catch (IllegalAccessException e) { + } catch (IllegalArgumentException e) { e.printStackTrace(); } } @@ -44,7 +44,7 @@ public class OfferBehaviour extends Component { public void initialize() { try { this.receiver = blockContainer.getBlockRelative(direction, parent.getRotation()); - } catch (IllegalAccessException e) { + } catch (IllegalArgumentException e) { e.printStackTrace(); } diff --git a/src/main/java/com/yes/yes/behaviours/PlaceBehaviour.java b/src/main/java/com/yes/yes/behaviours/PlaceBehaviour.java index 0ae0a1b..412e377 100644 --- a/src/main/java/com/yes/yes/behaviours/PlaceBehaviour.java +++ b/src/main/java/com/yes/yes/behaviours/PlaceBehaviour.java @@ -21,7 +21,7 @@ public class PlaceBehaviour extends Component { if (entity != null) { entity.trigger("placed", parent); } - } catch (IllegalAccessException ex) { + } catch (IllegalArgumentException ex) { ex.printStackTrace(); } } diff --git a/src/main/java/com/yes/yes/behaviours/ReceiveBehaviour.java b/src/main/java/com/yes/yes/behaviours/ReceiveBehaviour.java index 2d78eee..4d7f275 100644 --- a/src/main/java/com/yes/yes/behaviours/ReceiveBehaviour.java +++ b/src/main/java/com/yes/yes/behaviours/ReceiveBehaviour.java @@ -22,7 +22,7 @@ public class ReceiveBehaviour extends Component { if (blockContainer.getBlockRelative(direction, parent.getRotation()) == entity) { this.offerer = entity; } - } catch (IllegalAccessException e) { + } catch (IllegalArgumentException e) { e.printStackTrace(); } } @@ -31,7 +31,7 @@ public class ReceiveBehaviour extends Component { public void initialize() { try { this.offerer = blockContainer.getBlockRelative(direction, parent.getRotation()); - } catch (IllegalAccessException e) { + } catch (IllegalArgumentException e) { e.printStackTrace(); } diff --git a/src/main/java/com/yes/yes/utils/BlockContainer.java b/src/main/java/com/yes/yes/utils/BlockContainer.java index e741c93..5eb1a7e 100644 --- a/src/main/java/com/yes/yes/utils/BlockContainer.java +++ b/src/main/java/com/yes/yes/utils/BlockContainer.java @@ -6,9 +6,9 @@ import com.yes.yes.world.World; public record BlockContainer(World world, Coordinate blockCoordinate, Coordinate chunkCoordinate) { final static int MAX_RADIUS = 2; - public Entity getBlockAbsolute(Coordinate offset) throws IllegalAccessException { + public Entity getBlockAbsolute(Coordinate offset) throws IllegalArgumentException { if (Math.abs(offset.x) > MAX_RADIUS || Math.abs(offset.y) > MAX_RADIUS) - throw new IllegalAccessException(); + throw new IllegalArgumentException(); Coordinate localChunkCoordinate = new Coordinate(chunkCoordinate.x, chunkCoordinate.y); Coordinate localBlockCoordinate = new Coordinate(blockCoordinate.x + offset.x, blockCoordinate.y + offset.y); @@ -38,7 +38,7 @@ public record BlockContainer(World world, Coordinate blockCoordinate, Coordinate } // Only works with a valid direction - public Entity getBlockRelative(Coordinate direction, int rotation) throws IllegalAccessException { + public Entity getBlockRelative(Coordinate direction, int rotation) throws IllegalArgumentException { for (int i = 0; i < rotation % 4; i++) { direction = Direction.rotateRight(direction); }