diff --git a/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java b/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java index b22dca9f0..d833ebe25 100644 --- a/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java +++ b/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java @@ -108,9 +108,12 @@ public class VehicleConfig { public static ModConfigSpec.IntValue PRISM_TANK_SHOOT_COST_MODE_2; public static ModConfigSpec.IntValue HPJ11_HP; + public static ModConfigSpec.IntValue HPJ11_MAX_ENERGY; public static ModConfigSpec.DoubleValue HPJ11_DAMAGE; public static ModConfigSpec.DoubleValue HPJ11_EXPLOSION_DAMAGE; public static ModConfigSpec.DoubleValue HPJ11_EXPLOSION_RADIUS; + public static ModConfigSpec.IntValue HPJ11_SHOOT_COST; + public static ModConfigSpec.IntValue HPJ11_SEEK_COST; public static void init(ModConfigSpec.Builder builder) { builder.push("vehicle"); @@ -427,6 +430,9 @@ public class VehicleConfig { builder.comment("The health of HPJ-11"); HPJ11_HP = builder.defineInRange("hpj_11_hp", 350, 1, 10000000); + builder.comment("The max energy storage of HPJ-11"); + HPJ11_MAX_ENERGY = builder.defineInRange("hpj_11_max_energy", 5000000, 0, 2147483647); + builder.comment("The damage of HPJ-11"); HPJ11_DAMAGE = builder.defineInRange("hpj_11_damage", 20d, 1, 10000000); @@ -436,6 +442,12 @@ public class VehicleConfig { builder.comment("The explosion radius of HPJ-11"); HPJ11_EXPLOSION_RADIUS = builder.defineInRange("hpj_11_explosion_radius", 4d, 1, 50); + builder.comment("The energy cost of HPJ-11 per shoot"); + HPJ11_SHOOT_COST = builder.defineInRange("hpj_11_shoot_cost", 64, 0, 2147483647); + + builder.comment("The energy cost of HPJ-11 find a new target"); + HPJ11_SEEK_COST = builder.defineInRange("hpj_11_seek_cost", 1024, 0, 2147483647); + builder.pop(); builder.pop(); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Hpj11Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Hpj11Entity.java index f59cccb44..455c06b86 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Hpj11Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Hpj11Entity.java @@ -256,14 +256,17 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti return; } + if (this.getEnergy() <= VehicleConfig.HPJ11_SEEK_COST.get()) return; + Matrix4f transform = getBarrelTransform(1); Vector4f worldPosition = transformPosition(transform, 0f, 0.4f, 0); Vec3 barrelRootPos = new Vec3(worldPosition.x, worldPosition.y, worldPosition.z); if (entityData.get(TARGET_UUID).equals("none") && tickCount % 2 == 0) { - Entity naerestEntity = seekNearLivingEntity(barrelRootPos,-32.5,90,3,160, 0.3); + Entity naerestEntity = seekNearLivingEntity(barrelRootPos, -32.5, 90, 3, 160, 0.3); if (naerestEntity != null) { entityData.set(TARGET_UUID, naerestEntity.getStringUUID()); + this.consumeEnergy(VehicleConfig.HPJ11_SEEK_COST.get()); } } @@ -474,6 +477,7 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti @Override public void vehicleShoot(Player player, int type) { if (cannotFire) return; + if (this.getEnergy() < VehicleConfig.HPJ11_SHOOT_COST.get()) return; boolean hasCreativeAmmo = (getFirstPassenger() instanceof Player pPlayer && InventoryTool.hasCreativeAmmoBox(pPlayer)) || hasItem(ModItems.CREATIVE_AMMO_BOX.get()); @@ -496,6 +500,8 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti this.entityData.set(HEAT, this.entityData.get(HEAT) + 2); this.entityData.set(ANIM_TIME, 1); + this.consumeEnergy(VehicleConfig.HPJ11_SHOOT_COST.get()); + if (hasCreativeAmmo) return; this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1)); @@ -514,6 +520,8 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti @Override public void travel() { + if (this.getEnergy() <= 0) return; + Entity passenger = this.getFirstPassenger(); if (passenger != null) { float diffY = Mth.wrapDegrees(passenger.getYHeadRot() - this.getYRot()); @@ -547,6 +555,11 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti return this.cache; } + @Override + public int getMaxEnergy() { + return VehicleConfig.HPJ11_MAX_ENERGY.get(); + } + @Override public float getMaxHealth() { return VehicleConfig.HPJ11_HP.get(); diff --git a/src/main/resources/data/superbwarfare/recipe/hpj11_crafting.json b/src/main/resources/data/superbwarfare/recipe/hpj11_crafting.json new file mode 100644 index 000000000..e01367c86 --- /dev/null +++ b/src/main/resources/data/superbwarfare/recipe/hpj11_crafting.json @@ -0,0 +1,46 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "pattern": [ + "abc", + "def", + "ghg" + ], + "key": { + "a": { + "item": "superbwarfare:hpj_11_blueprint" + }, + "b": { + "item": "minecraft:observer" + }, + "c": { + "item": "minecraft:comparator" + }, + "d": { + "tag": "superbwarfare:storage_blocks/steel" + }, + "e": { + "item": "superbwarfare:cannon_core" + }, + "f": { + "item": "superbwarfare:large_motor" + }, + "g": { + "item": "minecraft:iron_ingot" + }, + "h": { + "item": "superbwarfare:medium_battery_pack" + } + }, + "result": { + "id": "superbwarfare:container", + "components": { + "minecraft:block_entity_data": { + "id": "superbwarfare:container", + "EntityType": "superbwarfare:hpj_11" + } + } + } +} + + diff --git a/src/main/resources/data/superbwarfare/recipe/hpj_11_smithing.json b/src/main/resources/data/superbwarfare/recipe/hpj_11_smithing.json deleted file mode 100644 index d76592783..000000000 --- a/src/main/resources/data/superbwarfare/recipe/hpj_11_smithing.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "type": "minecraft:smithing_transform", - "template": { - "item": "superbwarfare:hpj_11_blueprint" - }, - "base": { - "item": "superbwarfare:cannon_core" - }, - "addition": { - "tag": "superbwarfare:storage_blocks/steel" - }, - "result": { - "id": "superbwarfare:container", - "components": { - "minecraft:block_entity_data": { - "id": "superbwarfare:container", - "EntityType": "superbwarfare:hpj_11" - } - } - } -} \ No newline at end of file