调整载具撞击方块
This commit is contained in:
parent
68b80323ac
commit
04e78ee2ea
11 changed files with 69 additions and 33 deletions
|
@ -1,7 +1,7 @@
|
||||||
// 1.21.1 2025-03-27T19:21:19.6223541 Tags for minecraft:block mod id superbwarfare
|
// 1.21.1 2025-04-07T06:12:27.7140791 Tags for minecraft:block mod id superbwarfare
|
||||||
0acfd31854bf15f2c108138b3df7206bd2593e6b data/minecraft/tags/block/mineable/axe.json
|
0acfd31854bf15f2c108138b3df7206bd2593e6b data/minecraft/tags/block/mineable/axe.json
|
||||||
8965b7e0b3f7494b78b596ed00b9721b483b0796 data/minecraft/tags/block/mineable/pickaxe.json
|
8965b7e0b3f7494b78b596ed00b9721b483b0796 data/minecraft/tags/block/mineable/pickaxe.json
|
||||||
3da7f021790388a122717f16f51c7ec5232eebcb data/minecraft/tags/block/mineable/shovel.json
|
3da7f021790388a122717f16f51c7ec5232eebcb data/minecraft/tags/block/mineable/shovel.json
|
||||||
f42a8c01336e64b74da966f03d45ee0d60ac5d6b data/minecraft/tags/block/needs_iron_tool.json
|
f42a8c01336e64b74da966f03d45ee0d60ac5d6b data/minecraft/tags/block/needs_iron_tool.json
|
||||||
fd591943fd73212b7697be1f050450b2af15cac0 data/superbwarfare/tags/block/hard_collision.json
|
32d65f7120acb277f54e1a7d4f6163456b9d1030 data/superbwarfare/tags/block/hard_collision.json
|
||||||
2f52d564d89eb8a125f3dba5d99ec7cb3bc8d7ba data/superbwarfare/tags/block/soft_collision.json
|
72e1c9e318d4c8df58bc2b667c48ddb3c1e2d747 data/superbwarfare/tags/block/soft_collision.json
|
||||||
|
|
|
@ -3,9 +3,6 @@
|
||||||
"#minecraft:logs",
|
"#minecraft:logs",
|
||||||
"#minecraft:planks",
|
"#minecraft:planks",
|
||||||
"#c:glass_blocks",
|
"#c:glass_blocks",
|
||||||
"#c:glass_panes",
|
|
||||||
"#minecraft:wooden_slabs",
|
|
||||||
"#minecraft:wooden_stairs",
|
|
||||||
"minecraft:ice",
|
"minecraft:ice",
|
||||||
"minecraft:frosted_ice",
|
"minecraft:frosted_ice",
|
||||||
"minecraft:packed_ice",
|
"minecraft:packed_ice",
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
"#minecraft:doors",
|
"#minecraft:doors",
|
||||||
"#minecraft:trapdoors",
|
"#minecraft:trapdoors",
|
||||||
"#minecraft:walls",
|
"#minecraft:walls",
|
||||||
|
"#minecraft:wool",
|
||||||
|
"#minecraft:stairs",
|
||||||
|
"#minecraft:slabs",
|
||||||
|
"#c:glass_panes",
|
||||||
"minecraft:cactus",
|
"minecraft:cactus",
|
||||||
"minecraft:bamboo",
|
"minecraft:bamboo",
|
||||||
"minecraft:melon",
|
"minecraft:melon",
|
||||||
|
|
|
@ -8,6 +8,7 @@ public class VehicleConfig {
|
||||||
|
|
||||||
public static ModConfigSpec.BooleanValue COLLISION_DESTROY_BLOCKS;
|
public static ModConfigSpec.BooleanValue COLLISION_DESTROY_BLOCKS;
|
||||||
public static ModConfigSpec.BooleanValue COLLISION_DESTROY_HARD_BLOCKS;
|
public static ModConfigSpec.BooleanValue COLLISION_DESTROY_HARD_BLOCKS;
|
||||||
|
public static ModConfigSpec.BooleanValue COLLISION_DESTROY_BLOCKS_BEASTLY;
|
||||||
public static ModConfigSpec.BooleanValue VEHICLE_ITEM_PICKUP;
|
public static ModConfigSpec.BooleanValue VEHICLE_ITEM_PICKUP;
|
||||||
|
|
||||||
public static ModConfigSpec.ConfigValue<List<? extends String>> COLLISION_ENTITY_WHITELIST;
|
public static ModConfigSpec.ConfigValue<List<? extends String>> COLLISION_ENTITY_WHITELIST;
|
||||||
|
@ -113,6 +114,9 @@ public class VehicleConfig {
|
||||||
builder.comment("Allows vehicles to destroy hard blocks via collision");
|
builder.comment("Allows vehicles to destroy hard blocks via collision");
|
||||||
COLLISION_DESTROY_HARD_BLOCKS = builder.define("collision_destroy_hard_blocks", false);
|
COLLISION_DESTROY_HARD_BLOCKS = builder.define("collision_destroy_hard_blocks", false);
|
||||||
|
|
||||||
|
builder.comment("Allows vehicles to destroy blocks via collision like a beast");
|
||||||
|
COLLISION_DESTROY_BLOCKS_BEASTLY = builder.define("collision_destroy_blocks_beastly", false);
|
||||||
|
|
||||||
builder.comment("Allow vehicles to pick up items");
|
builder.comment("Allow vehicles to pick up items");
|
||||||
VEHICLE_ITEM_PICKUP = builder.define("vehicle_item_pickup", true);
|
VEHICLE_ITEM_PICKUP = builder.define("vehicle_item_pickup", true);
|
||||||
|
|
||||||
|
|
|
@ -38,11 +38,13 @@ public class ModBlockTagProvider extends BlockTagsProvider {
|
||||||
this.tag(BlockTags.MINEABLE_WITH_SHOVEL).add(ModBlocks.SANDBAG.get());
|
this.tag(BlockTags.MINEABLE_WITH_SHOVEL).add(ModBlocks.SANDBAG.get());
|
||||||
|
|
||||||
this.tag(ModTags.Blocks.SOFT_COLLISION)
|
this.tag(ModTags.Blocks.SOFT_COLLISION)
|
||||||
.addTags(BlockTags.LEAVES, BlockTags.FENCES, BlockTags.FENCE_GATES, BlockTags.DOORS, BlockTags.TRAPDOORS, BlockTags.WALLS)
|
.addTags(BlockTags.LEAVES, BlockTags.FENCES, BlockTags.FENCE_GATES, BlockTags.DOORS, BlockTags.TRAPDOORS, BlockTags.WALLS, BlockTags.WOOL,
|
||||||
|
BlockTags.STAIRS, BlockTags.SLABS, Tags.Blocks.GLASS_PANES)
|
||||||
.add(Blocks.CACTUS, Blocks.BAMBOO, Blocks.MELON, Blocks.PUMPKIN, Blocks.HAY_BLOCK, Blocks.BELL, Blocks.CHAIN, Blocks.SNOW_BLOCK,
|
.add(Blocks.CACTUS, Blocks.BAMBOO, Blocks.MELON, Blocks.PUMPKIN, Blocks.HAY_BLOCK, Blocks.BELL, Blocks.CHAIN, Blocks.SNOW_BLOCK,
|
||||||
Blocks.COBWEB, Blocks.MUSHROOM_STEM, Blocks.BROWN_MUSHROOM_BLOCK, Blocks.RED_MUSHROOM_BLOCK);
|
Blocks.COBWEB, Blocks.MUSHROOM_STEM, Blocks.BROWN_MUSHROOM_BLOCK, Blocks.RED_MUSHROOM_BLOCK);
|
||||||
|
|
||||||
this.tag(ModTags.Blocks.HARD_COLLISION)
|
this.tag(ModTags.Blocks.HARD_COLLISION)
|
||||||
.addTags(BlockTags.LOGS, BlockTags.PLANKS, Tags.Blocks.GLASS_BLOCKS, Tags.Blocks.GLASS_PANES, BlockTags.WOODEN_SLABS, BlockTags.WOODEN_STAIRS)
|
.addTags(BlockTags.LOGS, BlockTags.PLANKS, Tags.Blocks.GLASS_BLOCKS)
|
||||||
.add(Blocks.ICE, Blocks.FROSTED_ICE, Blocks.PACKED_ICE, Blocks.BLUE_ICE);
|
.add(Blocks.ICE, Blocks.FROSTED_ICE, Blocks.PACKED_ICE, Blocks.BLUE_ICE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,7 +236,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canCollideHardBlock() {
|
public boolean canCollideHardBlock() {
|
||||||
return getDeltaMovement().horizontalDistance() > 0.07 || this.entityData.get(POWER) > 0.12;
|
return getDeltaMovement().horizontalDistance() > 0.07 || Mth.abs(this.entityData.get(POWER)) > 0.12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canCollideHardBlock() {
|
public boolean canCollideHardBlock() {
|
||||||
return getDeltaMovement().horizontalDistance() > 0.09 || this.entityData.get(POWER) > 0.15;
|
return getDeltaMovement().horizontalDistance() > 0.09 || Mth.abs(this.entityData.get(POWER)) > 0.15;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleAmmo() {
|
private void handleAmmo() {
|
||||||
|
|
|
@ -224,6 +224,11 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canCollideHardBlock() {
|
||||||
|
return getDeltaMovement().horizontalDistance() > 0.07 || Mth.abs(this.entityData.get(POWER)) > 0.12;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void move(@NotNull MoverType movementType, @NotNull Vec3 movement) {
|
public void move(@NotNull MoverType movementType, @NotNull Vec3 movement) {
|
||||||
super.move(movementType, movement);
|
super.move(movementType, movement);
|
||||||
|
|
|
@ -292,6 +292,15 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canCollideHardBlock() {
|
||||||
|
return getDeltaMovement().horizontalDistance() > 0.05 || Mth.abs(this.entityData.get(POWER)) > 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canCollideBlockBeastly() {
|
||||||
|
return getDeltaMovement().horizontalDistance() > 0.3;
|
||||||
|
}
|
||||||
|
|
||||||
private void handleAmmo() {
|
private void handleAmmo() {
|
||||||
if (getWeaponIndex(0) == 0 || getWeaponIndex(0) == 1) {
|
if (getWeaponIndex(0) == 0 || getWeaponIndex(0) == 1) {
|
||||||
|
|
|
@ -349,10 +349,8 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public void collideBlock() {
|
public void collideBlock() {
|
||||||
if (level() instanceof ServerLevel) {
|
|
||||||
if (!VehicleConfig.COLLISION_DESTROY_BLOCKS.get()) return;
|
if (!VehicleConfig.COLLISION_DESTROY_BLOCKS.get()) return;
|
||||||
|
AABB aabb = getBoundingBox().inflate(0.1, -0.05, 0.1);
|
||||||
AABB aabb = getBoundingBox().move(this.getDeltaMovement().scale(0.5)).inflate(0.1, -0.05, 0.1);
|
|
||||||
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(ModTags.Blocks.SOFT_COLLISION)) {
|
if (blockstate.is(ModTags.Blocks.SOFT_COLLISION)) {
|
||||||
|
@ -360,13 +358,10 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void collideHardBlock() {
|
public void collideHardBlock() {
|
||||||
if (level() instanceof ServerLevel) {
|
|
||||||
if (!VehicleConfig.COLLISION_DESTROY_HARD_BLOCKS.get()) return;
|
if (!VehicleConfig.COLLISION_DESTROY_HARD_BLOCKS.get()) return;
|
||||||
|
AABB aabb = getBoundingBox().inflate(0.25, -0.05, 0.25);
|
||||||
AABB aabb = getBoundingBox().move(this.getDeltaMovement().scale(0.5)).inflate(0.1, -0.05, 0.1);
|
|
||||||
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(ModTags.Blocks.HARD_COLLISION)) {
|
if (blockstate.is(ModTags.Blocks.HARD_COLLISION)) {
|
||||||
|
@ -375,17 +370,36 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void collideBlockBeastly() {
|
||||||
|
if (!VehicleConfig.COLLISION_DESTROY_BLOCKS_BEASTLY.get()) return;
|
||||||
|
AABB aabb = getBoundingBox().inflate(0.25, -0.05, 0.25);
|
||||||
|
BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
|
||||||
|
BlockState blockstate = this.level().getBlockState(pos);
|
||||||
|
float hardness = blockstate.getBlock().defaultDestroyTime();
|
||||||
|
if (hardness > 0 && hardness <= 4) {
|
||||||
|
this.level().destroyBlock(pos, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canCollideHardBlock() {
|
public boolean canCollideHardBlock() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canCollideBlockBeastly() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void move(@NotNull MoverType movementType, @NotNull Vec3 movement) {
|
public void move(@NotNull MoverType movementType, @NotNull Vec3 movement) {
|
||||||
if (!this.level().isClientSide()) {
|
if (!this.level().isClientSide()) {
|
||||||
MobileVehicleEntity.IGNORE_ENTITY_GROUND_CHECK_STEPPING = true;
|
MobileVehicleEntity.IGNORE_ENTITY_GROUND_CHECK_STEPPING = true;
|
||||||
}
|
}
|
||||||
|
if (level() instanceof ServerLevel && canCollideBlockBeastly()) {
|
||||||
|
collideBlockBeastly();
|
||||||
|
}
|
||||||
|
|
||||||
super.move(movementType, movement);
|
super.move(movementType, movement);
|
||||||
if (level() instanceof ServerLevel) {
|
if (level() instanceof ServerLevel) {
|
||||||
if (this.horizontalCollision) {
|
if (this.horizontalCollision) {
|
||||||
|
|
|
@ -373,7 +373,8 @@ public abstract class VehicleEntity extends Entity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hurt(@NotNull DamageSource source, float amount) {
|
public boolean hurt(@NotNull DamageSource source, float amount) {
|
||||||
if (source.is(DamageTypes.CACTUS)) return false;
|
if (source.is(DamageTypes.CACTUS) || source.is(DamageTypes.SWEET_BERRY_BUSH) || source.is(DamageTypes.IN_WALL))
|
||||||
|
return false;
|
||||||
// 计算减伤后的伤害
|
// 计算减伤后的伤害
|
||||||
float computedAmount = damageModifier.compute(source, amount);
|
float computedAmount = damageModifier.compute(source, amount);
|
||||||
this.crash = source.is(ModDamageTypes.VEHICLE_STRIKE);
|
this.crash = source.is(ModDamageTypes.VEHICLE_STRIKE);
|
||||||
|
|
Loading…
Add table
Reference in a new issue