添加撞击破坏配置文件
This commit is contained in:
parent
e2f28c7787
commit
9dcee7a195
2 changed files with 20 additions and 3 deletions
|
@ -4,6 +4,9 @@ import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
|
|
||||||
public class VehicleConfig {
|
public class VehicleConfig {
|
||||||
|
|
||||||
|
public static ForgeConfigSpec.BooleanValue COLLISION_DESTROY_BLOCKS;
|
||||||
|
public static ForgeConfigSpec.BooleanValue COLLISION_DESTROY_HARD_BLOCKS;
|
||||||
|
|
||||||
public static ForgeConfigSpec.IntValue MK42_HP;
|
public static ForgeConfigSpec.IntValue MK42_HP;
|
||||||
public static ForgeConfigSpec.IntValue MK42_AP_DAMAGE;
|
public static ForgeConfigSpec.IntValue MK42_AP_DAMAGE;
|
||||||
public static ForgeConfigSpec.IntValue MK42_AP_EXPLOSION_DAMAGE;
|
public static ForgeConfigSpec.IntValue MK42_AP_EXPLOSION_DAMAGE;
|
||||||
|
@ -58,8 +61,17 @@ public class VehicleConfig {
|
||||||
public static ForgeConfigSpec.IntValue BMP_2_CANNON_EXPLOSION_DAMAGE;
|
public static ForgeConfigSpec.IntValue BMP_2_CANNON_EXPLOSION_DAMAGE;
|
||||||
public static ForgeConfigSpec.DoubleValue BMP_2_CANNON_EXPLOSION_RADIUS;
|
public static ForgeConfigSpec.DoubleValue BMP_2_CANNON_EXPLOSION_RADIUS;
|
||||||
|
|
||||||
|
|
||||||
public static void init(ForgeConfigSpec.Builder builder) {
|
public static void init(ForgeConfigSpec.Builder builder) {
|
||||||
|
builder.push("vehicle");
|
||||||
|
|
||||||
|
builder.comment("Allows vehicles to destroy blocks via collision");
|
||||||
|
COLLISION_DESTROY_BLOCKS = builder.define("collision_destroy_blocks", false);
|
||||||
|
|
||||||
|
builder.comment("Allows vehicles to destroy hard blocks via collision");
|
||||||
|
COLLISION_DESTROY_HARD_BLOCKS = builder.define("collision_destroy_hard_blocks", false);
|
||||||
|
|
||||||
|
builder.pop();
|
||||||
|
|
||||||
builder.push("mk_42");
|
builder.push("mk_42");
|
||||||
|
|
||||||
builder.comment("The HealthPoint of MK-42");
|
builder.comment("The HealthPoint of MK-42");
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.atsuishio.superbwarfare.entity.vehicle;
|
package com.atsuishio.superbwarfare.entity.vehicle;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
||||||
import com.atsuishio.superbwarfare.entity.C4Entity;
|
import com.atsuishio.superbwarfare.entity.C4Entity;
|
||||||
import com.atsuishio.superbwarfare.entity.TargetEntity;
|
import com.atsuishio.superbwarfare.entity.TargetEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.projectile.FlareDecoyEntity;
|
import com.atsuishio.superbwarfare.entity.projectile.FlareDecoyEntity;
|
||||||
|
@ -88,6 +89,8 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
||||||
|
|
||||||
public void collideBlock() {
|
public void collideBlock() {
|
||||||
if (level() instanceof ServerLevel) {
|
if (level() instanceof ServerLevel) {
|
||||||
|
if (!VehicleConfig.COLLISION_DESTROY_BLOCKS.get()) return;
|
||||||
|
|
||||||
AABB aabb = getBoundingBox().inflate(0.1).move(this.getDeltaMovement().scale(0.6));
|
AABB aabb = getBoundingBox().inflate(0.1).move(this.getDeltaMovement().scale(0.6));
|
||||||
BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
|
BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
|
||||||
BlockState blockstate = this.level().getBlockState(pos);
|
BlockState blockstate = this.level().getBlockState(pos);
|
||||||
|
@ -95,7 +98,6 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
||||||
|| blockstate.is(BlockTags.LEAVES) || blockstate.is(BlockTags.FENCES)
|
|| blockstate.is(BlockTags.LEAVES) || blockstate.is(BlockTags.FENCES)
|
||||||
|| blockstate.is(BlockTags.FENCE_GATES) || blockstate.is(BlockTags.DOORS)
|
|| blockstate.is(BlockTags.FENCE_GATES) || blockstate.is(BlockTags.DOORS)
|
||||||
|| blockstate.is(BlockTags.TRAPDOORS) || blockstate.is(Blocks.BAMBOO)
|
|| blockstate.is(BlockTags.TRAPDOORS) || blockstate.is(Blocks.BAMBOO)
|
||||||
|| blockstate.is(Tags.Blocks.GLASS) || blockstate.is(Tags.Blocks.GLASS_PANES)
|
|
||||||
|| blockstate.is(Blocks.MELON) || blockstate.is(Blocks.PUMPKIN)
|
|| blockstate.is(Blocks.MELON) || blockstate.is(Blocks.PUMPKIN)
|
||||||
|| blockstate.is(Blocks.HAY_BLOCK) || blockstate.is(Blocks.BELL)
|
|| blockstate.is(Blocks.HAY_BLOCK) || blockstate.is(Blocks.BELL)
|
||||||
|| blockstate.is(BlockTags.WALLS) || blockstate.is(Blocks.CHAIN)) {
|
|| blockstate.is(BlockTags.WALLS) || blockstate.is(Blocks.CHAIN)) {
|
||||||
|
@ -108,10 +110,13 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
||||||
|
|
||||||
public void collideHardBlock() {
|
public void collideHardBlock() {
|
||||||
if (level() instanceof ServerLevel) {
|
if (level() instanceof ServerLevel) {
|
||||||
|
if (!VehicleConfig.COLLISION_DESTROY_HARD_BLOCKS.get()) return;
|
||||||
|
|
||||||
AABB aabb = getBoundingBox().inflate(0.1).move(this.getDeltaMovement().scale(0.6));
|
AABB aabb = getBoundingBox().inflate(0.1).move(this.getDeltaMovement().scale(0.6));
|
||||||
BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
|
BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
|
||||||
BlockState blockstate = this.level().getBlockState(pos);
|
BlockState blockstate = this.level().getBlockState(pos);
|
||||||
if (blockstate.is(BlockTags.LOGS) || blockstate.is(BlockTags.PLANKS)) {
|
if (blockstate.is(BlockTags.LOGS) || blockstate.is(BlockTags.PLANKS)
|
||||||
|
|| blockstate.is(Tags.Blocks.GLASS) || blockstate.is(Tags.Blocks.GLASS_PANES)) {
|
||||||
this.level().destroyBlock(pos, true);
|
this.level().destroyBlock(pos, true);
|
||||||
this.setDeltaMovement(this.getDeltaMovement().scale(0.6));
|
this.setDeltaMovement(this.getDeltaMovement().scale(0.6));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue