mirror of
https://github.com/Stefan-5422/School-Programming-Projekt-022022.git
synced 2026-09-04 00:46:01 +02:00
Change wrong exception type
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class PlaceBehaviour extends Component {
|
||||
if (entity != null) {
|
||||
entity.trigger("placed", parent);
|
||||
}
|
||||
} catch (IllegalAccessException ex) {
|
||||
} catch (IllegalArgumentException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user