diff --git a/src/main/java/com/atsuishio/superbwarfare/block/entity/CreativeChargingStationBlockEntity.java b/src/main/java/com/atsuishio/superbwarfare/block/entity/CreativeChargingStationBlockEntity.java index c4fd53408..1ae935b92 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/entity/CreativeChargingStationBlockEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/block/entity/CreativeChargingStationBlockEntity.java @@ -19,11 +19,11 @@ import org.jetbrains.annotations.NotNull; * Energy Data Slot Code based on @GoryMoon's Chargers */ public class CreativeChargingStationBlockEntity extends BlockEntity { + public static final int CHARGE_RADIUS = 8; private LazyOptional energyHandler; - public CreativeChargingStationBlockEntity(BlockPos pos, BlockState state) { super(ModBlockEntities.CREATIVE_CHARGING_STATION.get(), pos, state); this.energyHandler = LazyOptional.of(() -> new EnergyStorage(2147483647)); @@ -39,20 +39,18 @@ public class CreativeChargingStationBlockEntity extends BlockEntity { } private void chargeEntity() { - assert this.level != null; + if (this.level == null) return; - this.level - .getEntitiesOfClass(Entity.class, new AABB(this.getBlockPos()).inflate(CHARGE_RADIUS)) + this.level.getEntitiesOfClass(Entity.class, new AABB(this.getBlockPos()).inflate(CHARGE_RADIUS)) .forEach(entity -> { if (entity instanceof IChargeEntity chargeEntity && chargeEntity.canCharge()) { - chargeEntity.charge(2147483647); + chargeEntity.charge(10000000); } }); } - private void chargeBlock() { - assert this.level != null; + if (this.level == null) return; for (Direction direction : Direction.values()) { var blockEntity = this.level.getBlockEntity(this.getBlockPos().relative(direction)); @@ -63,14 +61,13 @@ public class CreativeChargingStationBlockEntity extends BlockEntity { blockEntity.getCapability(ForgeCapabilities.ENERGY).ifPresent(energy -> { if (energy.canReceive() && energy.getEnergyStored() < energy.getMaxEnergyStored()) { - energy.receiveEnergy(2147483647, false); + energy.receiveEnergy(10000000, false); blockEntity.setChanged(); } }); } } - @Override public ClientboundBlockEntityDataPacket getUpdatePacket() { return ClientboundBlockEntityDataPacket.create(this); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/EnergyVehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/EnergyVehicleEntity.java index 77d7d038d..945fcfb50 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/EnergyVehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/EnergyVehicleEntity.java @@ -54,7 +54,9 @@ public class EnergyVehicleEntity extends VehicleEntity implements IChargeEntity @Override public void charge(int amount) { - this.setEnergy(Math.min(this.getEnergy() + amount, this.getMaxEnergy())); + long energy = (long) this.getEnergy() + (long) amount; + int e = energy > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) energy; + this.setEnergy(Math.min(e, this.getMaxEnergy())); } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java b/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java index 7df8ff6fa..53ad6e879 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java @@ -250,7 +250,8 @@ public class ModItems { public static final RegistryObject DRAGON_TEETH = block(ModBlocks.DRAGON_TEETH); public static final RegistryObject REFORGING_TABLE = block(ModBlocks.REFORGING_TABLE); public static final RegistryObject CHARGING_STATION = block(ModBlocks.CHARGING_STATION); - public static final RegistryObject CREATIVE_CHARGING_STATION = block(ModBlocks.CREATIVE_CHARGING_STATION); + public static final RegistryObject CREATIVE_CHARGING_STATION = BLOCKS.register("creative_charging_station", + () -> new BlockItem(ModBlocks.CREATIVE_CHARGING_STATION.get(), new Item.Properties().rarity(Rarity.EPIC))); public static final RegistryObject LEAD_BLOCK = block(ModBlocks.LEAD_BLOCK); public static final RegistryObject STEEL_BLOCK = block(ModBlocks.STEEL_BLOCK); public static final RegistryObject TUNGSTEN_BLOCK = block(ModBlocks.TUNGSTEN_BLOCK);