Skip to content

Commit 12e59d0

Browse files
committed
fix ammo manager does not work on ship
1 parent cb8fa79 commit 12e59d0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

common/src/main/java/com/github/litermc/vschunkloader/block/ammo/AmmoManagerBlockEntity.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import org.joml.primitives.AABBd;
1515
import org.valkyrienskies.core.api.ships.LoadedServerShip;
16+
import org.valkyrienskies.core.api.ships.ServerShip;
1617
import org.valkyrienskies.core.apigame.world.ServerShipWorldCore;
1718
import org.valkyrienskies.mod.common.VSGameUtilsKt;
1819

@@ -26,11 +27,17 @@ public AmmoManagerBlockEntity(final BlockPos pos, final BlockState state) {
2627
}
2728

2829
public AABBd getManageArea() {
29-
return this.manageArea;
30+
final ServerLevel level = (ServerLevel) (this.getLevel());
31+
final ServerShip ship = VSGameUtilsKt.getShipManagingPos(level, this.getBlockPos());
32+
if (ship == null) {
33+
return this.manageArea;
34+
}
35+
return this.manageArea.transform(ship.getShipToWorld(), new AABBd());
3036
}
3137

3238
public void serverTick() {
33-
final ServerShipWorldCore world = VSGameUtilsKt.getShipObjectWorld((ServerLevel) (this.getLevel()));
39+
final ServerLevel level = (ServerLevel) (this.getLevel());
40+
final ServerShipWorldCore world = VSGameUtilsKt.getShipObjectWorld(level);
3441
for (final LoadedServerShip ship : world.getLoadedShips().getIntersecting(this.getManageArea())) {
3542
final AmmoShipAttachment attachment = ship.getAttachment(AmmoShipAttachment.class);
3643
if (attachment != null) {

0 commit comments

Comments
 (0)