重置碰撞配置
This commit is contained in:
parent
ed023bebea
commit
490e340ea9
3 changed files with 16 additions and 23 deletions
|
@ -10,11 +10,10 @@ public class VehicleConfig {
|
||||||
public static ForgeConfigSpec.BooleanValue COLLISION_DESTROY_HARD_BLOCKS;
|
public static ForgeConfigSpec.BooleanValue COLLISION_DESTROY_HARD_BLOCKS;
|
||||||
public static ForgeConfigSpec.BooleanValue VEHICLE_ITEM_PICKUP;
|
public static ForgeConfigSpec.BooleanValue VEHICLE_ITEM_PICKUP;
|
||||||
|
|
||||||
public static ForgeConfigSpec.ConfigValue<List<? extends String>> COLLISION_ENTITY_BLACKLIST;
|
public static ForgeConfigSpec.ConfigValue<List<? extends String>> COLLISION_ENTITY_WHITELIST;
|
||||||
|
|
||||||
@SuppressWarnings("SpellCheckingInspection")
|
public static final List<? extends String> DEFAULT_COLLISION_ENTITY_WHITELIST =
|
||||||
public static final List<? extends String> DEFAULT_COLLISION_ENTITY_BLACKLIST =
|
List.of();
|
||||||
List.of("create:super_glue", "zombieawareness:scent", "mts:builder_rendering");
|
|
||||||
|
|
||||||
public static ForgeConfigSpec.IntValue REPAIR_COOLDOWN;
|
public static ForgeConfigSpec.IntValue REPAIR_COOLDOWN;
|
||||||
public static ForgeConfigSpec.DoubleValue REPAIR_AMOUNT;
|
public static ForgeConfigSpec.DoubleValue REPAIR_AMOUNT;
|
||||||
|
@ -101,9 +100,9 @@ public class VehicleConfig {
|
||||||
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);
|
||||||
|
|
||||||
builder.comment("List of entities that cannot be damaged by collision");
|
builder.comment("List of entities that can be damaged by collision");
|
||||||
COLLISION_ENTITY_BLACKLIST = builder.defineList("collision_entity_blacklist",
|
COLLISION_ENTITY_WHITELIST = builder.defineList("collision_entity_whitelist",
|
||||||
DEFAULT_COLLISION_ENTITY_BLACKLIST,
|
DEFAULT_COLLISION_ENTITY_WHITELIST,
|
||||||
e -> e instanceof String);
|
e -> e instanceof String);
|
||||||
|
|
||||||
builder.push("repair");
|
builder.push("repair");
|
||||||
|
|
|
@ -31,6 +31,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.entity.EntityTypeTest;
|
import net.minecraft.world.level.entity.EntityTypeTest;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.joml.Math;
|
import org.joml.Math;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
@ -316,19 +317,12 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity {
|
||||||
var entities = level().getEntities(EntityTypeTest.forClass(Entity.class), frontBox,
|
var entities = level().getEntities(EntityTypeTest.forClass(Entity.class), frontBox,
|
||||||
entity -> entity != this && entity != getFirstPassenger() && entity.getVehicle() == null)
|
entity -> entity != this && entity != getFirstPassenger() && entity.getVehicle() == null)
|
||||||
.stream().filter(entity -> {
|
.stream().filter(entity -> {
|
||||||
if (entity.isAlive()
|
if (entity.isAlive()) {
|
||||||
&& (entity instanceof VehicleEntity
|
var type = ForgeRegistries.ENTITY_TYPES.getKey(entity.getType());
|
||||||
|| entity instanceof Boat
|
if (type == null) return false;
|
||||||
|| entity instanceof Minecart
|
return (entity instanceof VehicleEntity || entity instanceof Boat || entity instanceof Minecart
|
||||||
|| (entity instanceof LivingEntity living && !(living instanceof Player player && player.isSpectator())))
|
|| (entity instanceof LivingEntity living && !(living instanceof Player player && player.isSpectator())))
|
||||||
) {
|
|| VehicleConfig.COLLISION_ENTITY_WHITELIST.get().contains(type.toString());
|
||||||
return true;
|
|
||||||
|
|
||||||
// todo 添加碰撞白名单
|
|
||||||
|
|
||||||
// var type = ForgeRegistries.ENTITY_TYPES.getKey(entity.getType());
|
|
||||||
// if (type == null) return false;
|
|
||||||
// return !VehicleConfig.COLLISION_ENTITY_BLACKLIST.get().contains(type.toString());
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,12 +103,12 @@ public class SeekTool {
|
||||||
return entity.isAlive()
|
return entity.isAlive()
|
||||||
&& !(entity instanceof ItemEntity || entity instanceof ExperienceOrb || entity instanceof HangingEntity || entity instanceof Projectile || entity instanceof ArmorStand || entity instanceof ClaymoreEntity || entity instanceof C4Entity || entity instanceof AreaEffectCloud)
|
&& !(entity instanceof ItemEntity || entity instanceof ExperienceOrb || entity instanceof HangingEntity || entity instanceof Projectile || entity instanceof ArmorStand || entity instanceof ClaymoreEntity || entity instanceof C4Entity || entity instanceof AreaEffectCloud)
|
||||||
&& !(entity instanceof Player player && player.isSpectator())
|
&& !(entity instanceof Player player && player.isSpectator())
|
||||||
&& excludedByConfig(entity);
|
|| includedByConfig(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean excludedByConfig(Entity entity) {
|
public static boolean includedByConfig(Entity entity) {
|
||||||
var type = ForgeRegistries.ENTITY_TYPES.getKey(entity.getType());
|
var type = ForgeRegistries.ENTITY_TYPES.getKey(entity.getType());
|
||||||
if (type == null) return false;
|
if (type == null) return false;
|
||||||
return !VehicleConfig.COLLISION_ENTITY_BLACKLIST.get().contains(type.toString());
|
return VehicleConfig.COLLISION_ENTITY_WHITELIST.get().contains(type.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue