Change wrong exception type

This commit is contained in:
Stone_Red
2022-05-19 12:06:54 +02:00
parent c1f7802a33
commit b047822cbb
4 changed files with 9 additions and 9 deletions
@@ -25,7 +25,7 @@ public class OfferBehaviour extends Component {
if (blockContainer.getBlockRelative(direction, parent.getRotation()) == entity) { if (blockContainer.getBlockRelative(direction, parent.getRotation()) == entity) {
this.receiver = entity; this.receiver = entity;
} }
} catch (IllegalAccessException e) { } catch (IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@@ -35,7 +35,7 @@ public class OfferBehaviour extends Component {
if (blockContainer.getBlockRelative(direction, parent.getRotation()) == entity) { if (blockContainer.getBlockRelative(direction, parent.getRotation()) == entity) {
this.parent.setData(dataKey, null); this.parent.setData(dataKey, null);
} }
} catch (IllegalAccessException e) { } catch (IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@@ -44,7 +44,7 @@ public class OfferBehaviour extends Component {
public void initialize() { public void initialize() {
try { try {
this.receiver = blockContainer.getBlockRelative(direction, parent.getRotation()); this.receiver = blockContainer.getBlockRelative(direction, parent.getRotation());
} catch (IllegalAccessException e) { } catch (IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -21,7 +21,7 @@ public class PlaceBehaviour extends Component {
if (entity != null) { if (entity != null) {
entity.trigger("placed", parent); entity.trigger("placed", parent);
} }
} catch (IllegalAccessException ex) { } catch (IllegalArgumentException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
@@ -22,7 +22,7 @@ public class ReceiveBehaviour extends Component {
if (blockContainer.getBlockRelative(direction, parent.getRotation()) == entity) { if (blockContainer.getBlockRelative(direction, parent.getRotation()) == entity) {
this.offerer = entity; this.offerer = entity;
} }
} catch (IllegalAccessException e) { } catch (IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@@ -31,7 +31,7 @@ public class ReceiveBehaviour extends Component {
public void initialize() { public void initialize() {
try { try {
this.offerer = blockContainer.getBlockRelative(direction, parent.getRotation()); this.offerer = blockContainer.getBlockRelative(direction, parent.getRotation());
} catch (IllegalAccessException e) { } catch (IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -6,9 +6,9 @@ import com.yes.yes.world.World;
public record BlockContainer(World world, Coordinate blockCoordinate, Coordinate chunkCoordinate) { public record BlockContainer(World world, Coordinate blockCoordinate, Coordinate chunkCoordinate) {
final static int MAX_RADIUS = 2; 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) 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 localChunkCoordinate = new Coordinate(chunkCoordinate.x, chunkCoordinate.y);
Coordinate localBlockCoordinate = new Coordinate(blockCoordinate.x + offset.x, blockCoordinate.y + offset.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 // 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++) { for (int i = 0; i < rotation % 4; i++) {
direction = Direction.rotateRight(direction); direction = Direction.rotateRight(direction);
} }