pre修改:修正BUG,进一步完善命令
This commit is contained in:
parent
7da5fc6c8d
commit
08aae0f1e1
|
|
@ -59,7 +59,7 @@ mod_name=Super Lead Rope
|
|||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=GPLv3
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=0.0.0.6-pre5
|
||||
mod_version=0.0.0.6-pre7
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
|
|
|
|||
|
|
@ -88,15 +88,17 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
|||
private Double maxLeashDistance;
|
||||
@Nullable
|
||||
private Double elasticDistanceScale;
|
||||
private int maxKeepLeashTicks;
|
||||
|
||||
/**
|
||||
* Instantiates a new Add leash.
|
||||
*
|
||||
* @param leashedEntity the leashed entity
|
||||
* @param holderEntity the holder entity
|
||||
* @param leashedEntity the leashed entity
|
||||
* @param holderEntity the holder entity
|
||||
* @param maxKeepLeashTicks the max keep leash ticks
|
||||
*/
|
||||
public AddLeash(Entity leashedEntity, Entity holderEntity) {
|
||||
this(leashedEntity, holderEntity, null, null);
|
||||
public AddLeash(Entity leashedEntity, Entity holderEntity, int maxKeepLeashTicks) {
|
||||
this(leashedEntity, holderEntity, null, null, maxKeepLeashTicks);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -106,12 +108,14 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
|||
* @param holderEntity the holder entity
|
||||
* @param maxLeashDistance the max leash distance
|
||||
* @param elasticDistanceScale the elastic distance scale
|
||||
* @param maxKeepLeashTicks the max keep leash ticks
|
||||
*/
|
||||
public AddLeash(Entity leashedEntity, Entity holderEntity, @Nullable Double maxLeashDistance, @Nullable Double elasticDistanceScale) {
|
||||
public AddLeash(Entity leashedEntity, Entity holderEntity, @Nullable Double maxLeashDistance, @Nullable Double elasticDistanceScale, int maxKeepLeashTicks) {
|
||||
super(leashedEntity);
|
||||
this.holderEntity = holderEntity;
|
||||
this.maxLeashDistance = maxLeashDistance;
|
||||
this.elasticDistanceScale = elasticDistanceScale;
|
||||
this.maxKeepLeashTicks = maxKeepLeashTicks;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -134,6 +138,26 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
|||
this.maxLeashDistance = maxLeashDistance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets max keep leash ticks.
|
||||
*
|
||||
* @param maxKeepLeashTicks the max keep leash ticks
|
||||
*/
|
||||
public void setMaxKeepLeashTicks(int maxKeepLeashTicks) {
|
||||
if (maxKeepLeashTicks < 0) return;
|
||||
markModified();
|
||||
this.maxKeepLeashTicks = maxKeepLeashTicks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets max keep leash ticks.
|
||||
*
|
||||
* @return the max keep leash ticks
|
||||
*/
|
||||
public int getMaxKeepLeashTicks() {
|
||||
return maxKeepLeashTicks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets holder entity.
|
||||
*
|
||||
|
|
@ -216,34 +240,38 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
|||
public static class TransferLeash extends SuperLeadRopeEvent {
|
||||
private final LeashHolder oldLeashHolder;
|
||||
private final Entity newLeashHolder;
|
||||
private int maxKeepLeashTicks;
|
||||
|
||||
/**
|
||||
* Instantiates a new Transfer leash.
|
||||
*
|
||||
* @param leashedEntity the leashed entity
|
||||
* @param holderEntity the holder entity
|
||||
* @param newLeashHolder the new leash holder
|
||||
* @param leashedEntity the leashed entity
|
||||
* @param holderEntity the holder entity
|
||||
* @param newLeashHolder the new leash holder
|
||||
* @param maxKeepLeashTicks the max keep leash ticks
|
||||
*/
|
||||
public TransferLeash(Entity leashedEntity, UUID holderEntity, Entity newLeashHolder) {
|
||||
this(leashedEntity, holderEntity, null, false , newLeashHolder);
|
||||
public TransferLeash(Entity leashedEntity, UUID holderEntity, Entity newLeashHolder, int maxKeepLeashTicks) {
|
||||
this(leashedEntity, holderEntity, null, false , newLeashHolder, maxKeepLeashTicks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new Transfer leash.
|
||||
*
|
||||
* @param leashedEntity the leashed entity
|
||||
* @param holderKnot the holder knot
|
||||
* @param newLeashHolder the new leash holder
|
||||
* @param leashedEntity the leashed entity
|
||||
* @param holderKnot the holder knot
|
||||
* @param newLeashHolder the new leash holder
|
||||
* @param maxKeepLeashTicks the max keep leash ticks
|
||||
*/
|
||||
public TransferLeash(Entity leashedEntity, BlockPos holderKnot, Entity newLeashHolder) {
|
||||
this(leashedEntity, null, holderKnot, true, newLeashHolder);
|
||||
public TransferLeash(Entity leashedEntity, BlockPos holderKnot, Entity newLeashHolder, int maxKeepLeashTicks) {
|
||||
this(leashedEntity, null, holderKnot, true, newLeashHolder, maxKeepLeashTicks);
|
||||
}
|
||||
private TransferLeash(Entity leashedEntity, @Nullable UUID holderEntity, @Nullable BlockPos holderPos, boolean isSuperLeadRopeKnot, Entity newLeashHolder) {
|
||||
private TransferLeash(Entity leashedEntity, @Nullable UUID holderEntity, @Nullable BlockPos holderPos, boolean isSuperLeadRopeKnot, Entity newLeashHolder, int maxKeepLeashTicks) {
|
||||
super(leashedEntity);
|
||||
if (isSuperLeadRopeKnot) {
|
||||
oldLeashHolder = new LeashHolder(holderPos);
|
||||
} else oldLeashHolder = new LeashHolder(holderEntity);
|
||||
this.newLeashHolder = newLeashHolder;
|
||||
this.maxKeepLeashTicks = maxKeepLeashTicks;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -263,10 +291,32 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
|||
public LeashHolder getOldLeashHolder() {
|
||||
return oldLeashHolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets max keep leash ticks.
|
||||
*
|
||||
* @param maxKeepLeashTicks the max keep leash ticks
|
||||
*/
|
||||
public void setMaxKeepLeashTicks(int maxKeepLeashTicks) {
|
||||
if(maxKeepLeashTicks < 0) return;
|
||||
markModified();
|
||||
this.maxKeepLeashTicks = maxKeepLeashTicks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets max keep leash ticks.
|
||||
*
|
||||
* @return the max keep leash ticks
|
||||
*/
|
||||
public int getMaxKeepLeashTicks() {
|
||||
return maxKeepLeashTicks;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The type Modify value.
|
||||
*
|
||||
* @param <T> the type parameter
|
||||
*/
|
||||
// MODIFY LEASH MAX_LEASH_LENGTH / ELASTIC_DISTANCE_SCALE
|
||||
@SuppressWarnings("unused")
|
||||
|
|
@ -281,10 +331,25 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
|||
private final Type type;
|
||||
private final Scope scope;
|
||||
|
||||
/**
|
||||
* The enum Type.
|
||||
*/
|
||||
public enum Type {
|
||||
/**
|
||||
* Max distance type.
|
||||
*/
|
||||
MAX_DISTANCE(Double.class),
|
||||
/**
|
||||
* Elastic distance scale type.
|
||||
*/
|
||||
ELASTIC_DISTANCE_SCALE(Double.class),
|
||||
/**
|
||||
* Max keep leash ticks type.
|
||||
*/
|
||||
MAX_KEEP_LEASH_TICKS(Integer.class),
|
||||
/**
|
||||
* Custom data type.
|
||||
*/
|
||||
CUSTOM_DATA(String.class); // 支持更多类型
|
||||
|
||||
private final Class<?> valueType;
|
||||
|
|
@ -293,16 +358,40 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
|||
this.valueType = valueType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets value type.
|
||||
*
|
||||
* @return the value type
|
||||
*/
|
||||
public Class<?> getValueType() {
|
||||
return valueType;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The enum Scope.
|
||||
*/
|
||||
public enum Scope {
|
||||
/**
|
||||
* Instance scope.
|
||||
*/
|
||||
INSTANCE,
|
||||
/**
|
||||
* Static scope.
|
||||
*/
|
||||
STATIC
|
||||
}
|
||||
|
||||
// 构造方法 - UUID holder
|
||||
/**
|
||||
* Instantiates a new Modify value.
|
||||
*
|
||||
* @param leashedEntity the leashed entity
|
||||
* @param holderUUID the holder uuid
|
||||
* @param oldValue the old value
|
||||
* @param newValue the new value
|
||||
* @param type the type
|
||||
*/
|
||||
// 构造方法 - UUID holder
|
||||
public ModifyValue(Entity leashedEntity, UUID holderUUID,
|
||||
@Nullable T oldValue, @Nullable T newValue,
|
||||
Type type) {
|
||||
|
|
@ -314,7 +403,16 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
|||
this.scope = Scope.INSTANCE;
|
||||
}
|
||||
|
||||
// 构造方法 - BlockPos holder
|
||||
/**
|
||||
* Instantiates a new Modify value.
|
||||
*
|
||||
* @param leashedEntity the leashed entity
|
||||
* @param knotBlockpos the knot blockpos
|
||||
* @param oldValue the old value
|
||||
* @param newValue the new value
|
||||
* @param type the type
|
||||
*/
|
||||
// 构造方法 - BlockPos holder
|
||||
public ModifyValue(Entity leashedEntity, BlockPos knotBlockpos,
|
||||
@Nullable T oldValue, @Nullable T newValue,
|
||||
Type type) {
|
||||
|
|
@ -326,7 +424,15 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
|||
this.scope = Scope.INSTANCE;
|
||||
}
|
||||
|
||||
// 构造方法 - 静态作用域
|
||||
/**
|
||||
* Instantiates a new Modify value.
|
||||
*
|
||||
* @param leashedEntity the leashed entity
|
||||
* @param oldValue the old value
|
||||
* @param newValue the new value
|
||||
* @param type the type
|
||||
*/
|
||||
// 构造方法 - 静态作用域
|
||||
public ModifyValue(Entity leashedEntity,
|
||||
@Nullable T oldValue, @Nullable T newValue,
|
||||
Type type) {
|
||||
|
|
@ -339,7 +445,14 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
|||
}
|
||||
|
||||
|
||||
// 类型安全的获取方法
|
||||
/**
|
||||
* Gets old value as.
|
||||
*
|
||||
* @param <R> the type parameter
|
||||
* @param clazz the clazz
|
||||
* @return the old value as
|
||||
*/
|
||||
// 类型安全的获取方法
|
||||
@SuppressWarnings("unchecked")
|
||||
public <R> R getOldValueAs(Class<R> clazz) {
|
||||
if (clazz.isInstance(oldValue)) {
|
||||
|
|
@ -348,6 +461,13 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets new value as.
|
||||
*
|
||||
* @param <R> the type parameter
|
||||
* @param clazz the clazz
|
||||
* @return the new value as
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <R> R getNewValueAs(Class<R> clazz) {
|
||||
if (clazz.isInstance(newValue)) {
|
||||
|
|
@ -356,16 +476,32 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets old value.
|
||||
*
|
||||
* @return the old value
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T getOldValue() {
|
||||
return (T) getOldValueAs(type.valueType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets new value.
|
||||
*
|
||||
* @return the new value
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T getNewValue() {
|
||||
return (T) getNewValueAs(type.valueType);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets new value.
|
||||
*
|
||||
* @param newValue the new value
|
||||
*/
|
||||
public void setNewValue(@Nullable T newValue) {
|
||||
if (newValue != null && !type.valueType.isInstance(newValue)) {
|
||||
throw new IllegalArgumentException(
|
||||
|
|
|
|||
|
|
@ -267,6 +267,16 @@ public interface ILeashData extends INBTSerializable<CompoundTag> {
|
|||
* ---------------------- */
|
||||
boolean setMaxDistance(Entity holder, Double distance);
|
||||
|
||||
/**
|
||||
* Sets max distance.
|
||||
*
|
||||
* @param holder the holder
|
||||
* @param distance the distance
|
||||
* @param reserved the reserved
|
||||
* @return the max distance
|
||||
*/
|
||||
boolean setMaxDistance(Entity holder, Double distance, String reserved);
|
||||
|
||||
/**
|
||||
* Sets max distance.
|
||||
*
|
||||
|
|
@ -297,6 +307,17 @@ public interface ILeashData extends INBTSerializable<CompoundTag> {
|
|||
*/
|
||||
boolean setMaxDistance(UUID holderUUID, Double distance);
|
||||
|
||||
/**
|
||||
* Sets max distance.
|
||||
*
|
||||
* @param holderUUID the holder uuid
|
||||
* @param distance the distance
|
||||
* @param reserved the reserved
|
||||
* @return the max distance
|
||||
*/
|
||||
boolean setMaxDistance(UUID holderUUID, Double distance, String reserved);
|
||||
|
||||
|
||||
/**
|
||||
* Sets max distance.
|
||||
*
|
||||
|
|
@ -327,6 +348,16 @@ public interface ILeashData extends INBTSerializable<CompoundTag> {
|
|||
*/
|
||||
boolean setMaxDistance(BlockPos knotPos, Double distance);
|
||||
|
||||
/**
|
||||
* Sets max distance.
|
||||
*
|
||||
* @param knotPos the knot pos
|
||||
* @param distance the distance
|
||||
* @param reserved the reserved
|
||||
* @return the max distance
|
||||
*/
|
||||
boolean setMaxDistance(BlockPos knotPos, Double distance, String reserved);
|
||||
|
||||
/**
|
||||
* Sets max distance.
|
||||
*
|
||||
|
|
@ -357,6 +388,7 @@ public interface ILeashData extends INBTSerializable<CompoundTag> {
|
|||
*/
|
||||
boolean setElasticDistanceScale(Entity holder, Double scale);
|
||||
|
||||
|
||||
/**
|
||||
* Sets elastic distance scale.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -232,7 +232,37 @@ public record LeashInfo(
|
|||
!isKnot ? Optional.of(entity.getUUID()) : Optional.empty(),
|
||||
Optional.of(entity.getId()),
|
||||
marks, newReserved, maxDistance, elasticDistanceScale,
|
||||
keepLeashTicks, maxKeepLeashTicks
|
||||
maxKeepLeashTicks, maxKeepLeashTicks
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer holder leash info.
|
||||
*
|
||||
* @param entity the entity
|
||||
* @param maxKeepLeashTicks the max keep leash ticks
|
||||
* @return the leash info
|
||||
*/
|
||||
public LeashInfo transferHolder(Entity entity, int maxKeepLeashTicks) {
|
||||
return transferHolder(entity, maxKeepLeashTicks, reserved);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer holder leash info.
|
||||
*
|
||||
* @param entity the entity
|
||||
* @param maxKeepLeashTicks the max keep leash ticks
|
||||
* @param newReserved the new reserved
|
||||
* @return the leash info
|
||||
*/
|
||||
public LeashInfo transferHolder(Entity entity, int maxKeepLeashTicks, String newReserved) {
|
||||
boolean isKnot = SuperLeadRopeApi.isSuperLeadKnot(entity);
|
||||
return new LeashInfo(
|
||||
isKnot ? Optional.of(SuperLeadRopeApi.getSuperLeadKnotPos(entity)) : Optional.empty(),
|
||||
!isKnot ? Optional.of(entity.getUUID()) : Optional.empty(),
|
||||
Optional.of(entity.getId()),
|
||||
marks, newReserved, maxDistance, elasticDistanceScale,
|
||||
maxKeepLeashTicks, maxKeepLeashTicks
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package top.r3944realms.superleadrope.config;
|
||||
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
|
|
@ -120,7 +121,7 @@ public class LeashCommonConfig {
|
|||
*
|
||||
* @param builder the builder
|
||||
*/
|
||||
public Common(ForgeConfigSpec.Builder builder) {
|
||||
public Common(ForgeConfigSpec.@NotNull Builder builder) {
|
||||
// ===== Command =====
|
||||
builder.push("Command");
|
||||
enableSLPModCommandPrefix = builder
|
||||
|
|
@ -153,11 +154,11 @@ public class LeashCommonConfig {
|
|||
builder.push("LeashSettings");
|
||||
maxLeashLength = builder
|
||||
.comment("Maximum leash distance (in blocks) for any entity")
|
||||
.defineInRange("maxLeashLength", 6.0, 1.0, 256.0);
|
||||
.defineInRange("maxLeashLength", 6.0, LeashConfigManager.MAX_DISTANCE_MIN_VALUE, LeashConfigManager.MAX_DISTANCE_MAX_VALUE);
|
||||
|
||||
elasticDistanceScale = builder
|
||||
.comment("Default elastic distance for the Super Lead rope")
|
||||
.defineInRange("elasticDistanceScale", 1.0, 0.2, 4.0);
|
||||
.defineInRange("elasticDistanceScale", 1.0, LeashConfigManager.ELASTIC_DISTANCE_MIN_VALUE, LeashConfigManager.ELASTIC_DISTANCE_MAX_VALUE);
|
||||
|
||||
extremeSnapFactor = builder
|
||||
.comment("Leash break factor = maxDistance * factor")
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ import net.minecraft.tags.TagKey;
|
|||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
import top.r3944realms.superleadrope.SuperLeadRope;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -33,16 +35,33 @@ import static top.r3944realms.superleadrope.config.LeashCommonConfig.Common.OFFS
|
|||
/**
|
||||
* The type Leash config manager.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class LeashConfigManager {
|
||||
// ========== 最值检测 ==========
|
||||
/**
|
||||
* The constant MAX_DISTANCE_CHECK.
|
||||
*/
|
||||
// ========== 最值检测 ==========
|
||||
public static final Predicate<Double> MAX_DISTANCE_CHECK = distance -> distance == null || (distance >= 1.0 && distance <= 256.0);
|
||||
public static final Double MAX_DISTANCE_MAX_VALUE = 256.0;
|
||||
/**
|
||||
* The constant MAX_DISTANCE_MIN_VALUE.
|
||||
*/
|
||||
public static final Double MAX_DISTANCE_MIN_VALUE = 1.0;
|
||||
/**
|
||||
* The constant MAX_DISTANCE_CHECK.
|
||||
*/
|
||||
public static final Predicate<Double> MAX_DISTANCE_CHECK = distance -> distance == null || (distance >= MAX_DISTANCE_MIN_VALUE && distance <= MAX_DISTANCE_MAX_VALUE);
|
||||
/**
|
||||
* The constant ELASTIC_DISTANCE_CHECK.
|
||||
*/
|
||||
public static final Predicate<Double> ELASTIC_DISTANCE_CHECK = distance -> distance == null || (distance >= 0.2 && distance <= 4.0);
|
||||
public static final Double ELASTIC_DISTANCE_MAX_VALUE = 4.0;
|
||||
/**
|
||||
* The constant ELASTIC_DISTANCE_MIN_VALUE.
|
||||
*/
|
||||
public static final Double ELASTIC_DISTANCE_MIN_VALUE = 0.2;
|
||||
/**
|
||||
* The constant ELASTIC_DISTANCE_CHECK.
|
||||
*/
|
||||
public static final Predicate<Double> ELASTIC_DISTANCE_CHECK = distance -> distance == null || (distance >= ELASTIC_DISTANCE_MIN_VALUE && distance <= ELASTIC_DISTANCE_MAX_VALUE);
|
||||
// ========== 偏移映射 ==========
|
||||
private final Map<String, double[]> entityHolderMap = new ConcurrentHashMap<>();
|
||||
private final Map<String, double[]> tagHolderMap = new ConcurrentHashMap<>();
|
||||
|
|
@ -77,7 +96,7 @@ public class LeashConfigManager {
|
|||
}
|
||||
|
||||
// ================== 偏移解析 ==================
|
||||
private Map<String, Map<String, double[]>> parseOffsetList(List<? extends String> offsetConfigs) {
|
||||
private @NotNull @Unmodifiable Map<String, Map<String, double[]>> parseOffsetList(@NotNull List<? extends String> offsetConfigs) {
|
||||
Map<String, double[]> entityMap = new HashMap<>();
|
||||
Map<String, double[]> tagMap = new HashMap<>();
|
||||
Map<String, double[]> modMap = new HashMap<>();
|
||||
|
|
@ -131,7 +150,7 @@ public class LeashConfigManager {
|
|||
|
||||
// ================== 获取偏移 ==================
|
||||
private double[] getOffset(String entityId, String modId, List<String> tags,
|
||||
Map<String,double[]> entityMap,
|
||||
@NotNull Map<String,double[]> entityMap,
|
||||
Map<String,double[]> tagMap,
|
||||
Map<String,double[]> modMap) {
|
||||
|
||||
|
|
@ -148,7 +167,7 @@ public class LeashConfigManager {
|
|||
* @return the default entity offset
|
||||
*/
|
||||
@SuppressWarnings({"DuplicatedCode", "deprecation"})
|
||||
public Vec3 getDefaultEntityOffset(EntityType<?> type) {
|
||||
public Vec3 getDefaultEntityOffset(@NotNull EntityType<?> type) {
|
||||
String entityId = type.builtInRegistryHolder().key().location().toString();
|
||||
String modId = entityId.split(":")[0];
|
||||
List<String> tags = new ArrayList<>();
|
||||
|
|
@ -165,7 +184,7 @@ public class LeashConfigManager {
|
|||
* @return the default holder offset
|
||||
*/
|
||||
@SuppressWarnings({"DuplicatedCode", "deprecation"})
|
||||
public Vec3 getDefaultHolderOffset(EntityType<?> type) {
|
||||
public Vec3 getDefaultHolderOffset(@NotNull EntityType<?> type) {
|
||||
String entityId = type.builtInRegistryHolder().key().location().toString();
|
||||
String modId = entityId.split(":")[0];
|
||||
List<String> tags = new ArrayList<>();
|
||||
|
|
@ -181,7 +200,7 @@ public class LeashConfigManager {
|
|||
* @param entity the entity
|
||||
* @return the default entity offset
|
||||
*/
|
||||
public Vec3 getDefaultEntityOffset(Entity entity) { return getDefaultEntityOffset(entity.getType()); }
|
||||
public Vec3 getDefaultEntityOffset(@NotNull Entity entity) { return getDefaultEntityOffset(entity.getType()); }
|
||||
|
||||
/**
|
||||
* Gets default holder offset.
|
||||
|
|
@ -189,7 +208,7 @@ public class LeashConfigManager {
|
|||
* @param entity the entity
|
||||
* @return the default holder offset
|
||||
*/
|
||||
public Vec3 getDefaultHolderOffset(Entity entity) { return getDefaultHolderOffset(entity.getType()); }
|
||||
public Vec3 getDefaultHolderOffset(@NotNull Entity entity) { return getDefaultHolderOffset(entity.getType()); }
|
||||
|
||||
/**
|
||||
* Gets teleport whitelist.
|
||||
|
|
@ -206,7 +225,7 @@ public class LeashConfigManager {
|
|||
* @return the boolean
|
||||
*/
|
||||
@SuppressWarnings({"DuplicatedCode", "deprecation"})
|
||||
public boolean isEntityTeleportAllowed(EntityType<?> type) {
|
||||
public boolean isEntityTeleportAllowed(@NotNull EntityType<?> type) {
|
||||
String entityId = type.builtInRegistryHolder().key().location().toString();
|
||||
String modId = entityId.split(":")[0];
|
||||
|
||||
|
|
@ -231,7 +250,7 @@ public class LeashConfigManager {
|
|||
* @param entity the entity
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isEntityTeleportAllowed(Entity entity) { return isEntityTeleportAllowed(entity.getType()); }
|
||||
public boolean isEntityTeleportAllowed(@NotNull Entity entity) { return isEntityTeleportAllowed(entity.getType()); }
|
||||
|
||||
/**
|
||||
* Gets command prefix.
|
||||
|
|
@ -401,7 +420,7 @@ public class LeashConfigManager {
|
|||
*
|
||||
* @param manager the manager
|
||||
*/
|
||||
public static void loading(LeashConfigManager manager) {
|
||||
public static void loading(@NotNull LeashConfigManager manager) {
|
||||
manager.reloadAll();
|
||||
}
|
||||
|
||||
|
|
@ -410,7 +429,7 @@ public class LeashConfigManager {
|
|||
*
|
||||
* @param manager the manager
|
||||
*/
|
||||
public static void reloading(LeashConfigManager manager) {
|
||||
public static void reloading(@NotNull LeashConfigManager manager) {
|
||||
manager.reloadAll();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ public class LeashDataImpl implements ILeashData {
|
|||
return false;
|
||||
}
|
||||
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(maxDistance) || !LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(elasticDistanceScale)) return false;
|
||||
SuperLeadRopeEvent.AddLeash event = new SuperLeadRopeEvent.AddLeash(holder, this.entity, maxDistance, elasticDistanceScale);
|
||||
SuperLeadRopeEvent.AddLeash event = new SuperLeadRopeEvent.AddLeash(this.entity, holder, maxDistance, elasticDistanceScale, maxKeepLeashTicks);
|
||||
//再次检查
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.MAX_DISTANCE_CHECK.test(event.getMaxLeashDistance()) && LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(event.getElasticDistanceScale()))) return false;
|
||||
if (!canBeLeashed()) {
|
||||
|
|
@ -311,7 +311,7 @@ public class LeashDataImpl implements ILeashData {
|
|||
reserved,
|
||||
event.getMaxLeashDistance(),
|
||||
event.getElasticDistanceScale(),
|
||||
maxKeepLeashTicks,
|
||||
event.getMaxKeepLeashTicks(),
|
||||
maxKeepLeashTicks
|
||||
);
|
||||
|
||||
|
|
@ -383,6 +383,13 @@ public class LeashDataImpl implements ILeashData {
|
|||
setMaxDistance(holder.getUUID(), newMaxDistance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setMaxDistance(Entity holder, Double distance, String reserved) {
|
||||
return holder instanceof SuperLeashKnotEntity superLeashKnotEntity ?
|
||||
setMaxDistance(superLeashKnotEntity.getPos(), distance, reserved) :
|
||||
setMaxDistance(holder.getUUID(),distance , reserved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setMaxDistance(Entity holder, @Nullable Double newMaxDistance, int newMaxKeepLeashTicks) {
|
||||
return holder instanceof SuperLeashKnotEntity superLeashKnotEntity ?
|
||||
|
|
@ -415,6 +422,24 @@ public class LeashDataImpl implements ILeashData {
|
|||
));
|
||||
}
|
||||
|
||||
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
||||
@Override
|
||||
public boolean setMaxDistance(UUID holderUUID, Double newMaxDistance, String reserved) {
|
||||
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return false;
|
||||
SuperLeadRopeEvent.ModifyValue<Double> event = new SuperLeadRopeEvent.ModifyValue<>(this.entity, holderUUID, leashHolders.get(holderUUID).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE);
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.MAX_DISTANCE_CHECK.test(event.getNewValue()))) return false;
|
||||
return updateLeashInfo(leashHolders, holderUUID, old -> new LeashInfo(
|
||||
old.holderUUIDOpt().get(),
|
||||
old.holderIdOpt().get(),
|
||||
old.marks(),
|
||||
reserved,
|
||||
event.getNewValue(),
|
||||
old.elasticDistanceScale(),
|
||||
old.keepLeashTicks(),
|
||||
old.maxKeepLeashTicks()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets max distance inner.
|
||||
*
|
||||
|
|
@ -492,6 +517,24 @@ public class LeashDataImpl implements ILeashData {
|
|||
));
|
||||
}
|
||||
|
||||
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
||||
@Override
|
||||
public boolean setMaxDistance(BlockPos knotPos, Double newMaxDistance, String reserved) {
|
||||
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return false;
|
||||
SuperLeadRopeEvent.ModifyValue<Double> event = new SuperLeadRopeEvent.ModifyValue<>(this.entity, knotPos, leashKnots.get(knotPos).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE);
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.MAX_DISTANCE_CHECK.test(event.getNewValue()))) return false;
|
||||
return updateLeashInfo(leashKnots, knotPos, old -> new LeashInfo(
|
||||
old.blockPosOpt().get(),
|
||||
old.holderIdOpt().get(),
|
||||
old.marks(),
|
||||
reserved,
|
||||
event.getNewValue(),
|
||||
old.elasticDistanceScale(),
|
||||
old.keepLeashTicks(),
|
||||
old.maxKeepLeashTicks()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets max distance inner.
|
||||
*
|
||||
|
|
@ -1122,14 +1165,17 @@ public class LeashDataImpl implements ILeashData {
|
|||
// 将拴绳持有者转移到新实体(非拴绳结 -> 任意)
|
||||
@Override
|
||||
public boolean transferLeash(UUID oldHolderUUID, Entity newHolder) {
|
||||
if(MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.TransferLeash(this.entity, oldHolderUUID, newHolder))) return false;
|
||||
LeashInfo preInfo = leashHolders.get(oldHolderUUID);
|
||||
if(preInfo == null) return false;
|
||||
SuperLeadRopeEvent.TransferLeash event = new SuperLeadRopeEvent.TransferLeash(this.entity, oldHolderUUID, newHolder, preInfo.maxKeepLeashTicks());
|
||||
if(MinecraftForge.EVENT_BUS.post(event)) return false;
|
||||
LeashInfo info = leashHolders.remove(oldHolderUUID);
|
||||
if (info == null || newHolder == null) return false;
|
||||
if(newHolder instanceof SuperLeashKnotEntity superLeashKnotEntity) {
|
||||
LeashInfo leashInfo = info.transferHolder(superLeashKnotEntity);
|
||||
LeashInfo leashInfo = info.transferHolder(superLeashKnotEntity, event.getMaxKeepLeashTicks());
|
||||
leashKnots.put(superLeashKnotEntity.getPos(), leashInfo);
|
||||
} else {
|
||||
LeashInfo leashInfo = info.transferHolder(newHolder);
|
||||
LeashInfo leashInfo = info.transferHolder(newHolder, event.getMaxKeepLeashTicks());
|
||||
leashHolders.put(newHolder.getUUID(), leashInfo);
|
||||
}
|
||||
LeashStateInnerAPI.Operations.transfer(entity, oldHolderUUID, newHolder);
|
||||
|
|
@ -1138,14 +1184,17 @@ public class LeashDataImpl implements ILeashData {
|
|||
}
|
||||
@Override
|
||||
public boolean transferLeash(UUID oldHolderUUID, Entity newHolder, String reserved) {
|
||||
if(MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.TransferLeash(this.entity, oldHolderUUID, newHolder))) return false;
|
||||
LeashInfo preInfo = leashHolders.get(oldHolderUUID);
|
||||
if(preInfo == null) return false;
|
||||
SuperLeadRopeEvent.TransferLeash event = new SuperLeadRopeEvent.TransferLeash(this.entity, oldHolderUUID, newHolder, preInfo.maxKeepLeashTicks());
|
||||
if(MinecraftForge.EVENT_BUS.post(event)) return false;
|
||||
LeashInfo info = leashHolders.remove(oldHolderUUID);
|
||||
if (info == null || newHolder == null) return false;
|
||||
if(newHolder instanceof SuperLeashKnotEntity superLeashKnotEntity) {
|
||||
LeashInfo leashInfo = info.transferHolder(superLeashKnotEntity, reserved);
|
||||
LeashInfo leashInfo = info.transferHolder(superLeashKnotEntity, event.getMaxKeepLeashTicks(), reserved);
|
||||
leashKnots.put(superLeashKnotEntity.getPos(), leashInfo);
|
||||
} else {
|
||||
LeashInfo leashInfo = info.transferHolder(newHolder, reserved);
|
||||
LeashInfo leashInfo = info.transferHolder(newHolder, event.getMaxKeepLeashTicks(), reserved);
|
||||
leashHolders.put(newHolder.getUUID(), leashInfo);
|
||||
}
|
||||
LeashStateInnerAPI.Operations.transfer(entity, oldHolderUUID, newHolder);
|
||||
|
|
@ -1155,14 +1204,17 @@ public class LeashDataImpl implements ILeashData {
|
|||
|
||||
@Override
|
||||
public boolean transferLeash(BlockPos knotPos, Entity newHolder) {
|
||||
if(MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.TransferLeash(this.entity, knotPos, newHolder))) return false;
|
||||
LeashInfo preInfo = leashKnots.get(knotPos);
|
||||
if(preInfo == null) return false;
|
||||
SuperLeadRopeEvent.TransferLeash event = new SuperLeadRopeEvent.TransferLeash(this.entity, knotPos, newHolder, preInfo.maxKeepLeashTicks());
|
||||
if (MinecraftForge.EVENT_BUS.post(event)) return false;
|
||||
LeashInfo info = leashKnots.remove(knotPos);
|
||||
if (info == null || newHolder == null) return false;
|
||||
if(newHolder instanceof SuperLeashKnotEntity superLeashKnotEntity) {
|
||||
LeashInfo leashInfo = info.transferHolder(superLeashKnotEntity);
|
||||
LeashInfo leashInfo = info.transferHolder(superLeashKnotEntity, event.getMaxKeepLeashTicks());
|
||||
leashKnots.put(superLeashKnotEntity.getPos(), leashInfo);
|
||||
} else {
|
||||
LeashInfo leashInfo = info.transferHolder(newHolder);
|
||||
LeashInfo leashInfo = info.transferHolder(newHolder, event.getMaxKeepLeashTicks());
|
||||
leashHolders.put(newHolder.getUUID(), leashInfo);
|
||||
}
|
||||
LeashStateInnerAPI.Operations.transfer(entity, knotPos, newHolder);
|
||||
|
|
@ -1172,14 +1224,17 @@ public class LeashDataImpl implements ILeashData {
|
|||
|
||||
@Override
|
||||
public boolean transferLeash(BlockPos knotPos, Entity newHolder, String reserved) {
|
||||
if(MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.TransferLeash(this.entity, knotPos, newHolder))) return false;
|
||||
LeashInfo preInfo = leashKnots.get(knotPos);
|
||||
if(preInfo == null) return false;
|
||||
SuperLeadRopeEvent.TransferLeash event = new SuperLeadRopeEvent.TransferLeash(this.entity, knotPos, newHolder, preInfo.maxKeepLeashTicks());
|
||||
if(MinecraftForge.EVENT_BUS.post(event)) return false;
|
||||
LeashInfo info = leashKnots.remove(knotPos);
|
||||
if (info == null || newHolder == null) return false;
|
||||
if(newHolder instanceof SuperLeashKnotEntity superLeashKnotEntity) {
|
||||
LeashInfo leashInfo = info.transferHolder(superLeashKnotEntity, reserved);
|
||||
LeashInfo leashInfo = info.transferHolder(superLeashKnotEntity, event.getMaxKeepLeashTicks(), reserved);
|
||||
leashKnots.put(superLeashKnotEntity.getPos(), leashInfo);
|
||||
} else {
|
||||
LeashInfo leashInfo = info.transferHolder(newHolder, reserved);
|
||||
LeashInfo leashInfo = info.transferHolder(newHolder, event.getMaxKeepLeashTicks(), reserved);
|
||||
leashHolders.put(newHolder.getUUID(), leashInfo);
|
||||
}
|
||||
LeashStateInnerAPI.Operations.transfer(entity, knotPos, newHolder);
|
||||
|
|
|
|||
|
|
@ -18,8 +18,13 @@ package top.r3944realms.superleadrope.content.command;
|
|||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import top.r3944realms.superleadrope.CommonEventHandler;
|
||||
import top.r3944realms.superleadrope.SuperLeadRope;
|
||||
import top.r3944realms.superleadrope.content.entity.SuperLeashKnotEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -35,6 +40,27 @@ public class Command {
|
|||
* The constant SHOULD_USE_PREFIX.
|
||||
*/
|
||||
public static boolean SHOULD_USE_PREFIX = CommonEventHandler.leashConfigManager.isCommandPrefixEnabled();
|
||||
/**
|
||||
* The constant BASE_.
|
||||
*/
|
||||
public static final String BASE_ = SuperLeadRope.MOD_ID + ".command.";
|
||||
/**
|
||||
* The constant ABBREVIATION.
|
||||
*/
|
||||
public static final String ABBREVIATION = BASE_ + "abbreviation";
|
||||
public static final String BLOCK_POS = BASE_ + ".block_pos";
|
||||
|
||||
public static final int MAX_SHOW_NUMBER = 4;
|
||||
public static Component getSLPName(Entity entity) {
|
||||
if (entity instanceof SuperLeashKnotEntity superLeashKnot) {
|
||||
BlockPos pos = superLeashKnot.getPos();
|
||||
return Component.translatable(BLOCK_POS, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
return entity.getName();
|
||||
}
|
||||
public static Component getSLPName(BlockPos pos) {
|
||||
return Component.translatable(BLOCK_POS, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets liter argument builder of css.
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -27,7 +27,7 @@ public class LeashStateCommand {
|
|||
*
|
||||
* @param dispatcher the dispatcher
|
||||
*/
|
||||
// 获取State
|
||||
// 获取State
|
||||
// 设置State
|
||||
// <addApplyEntity/setApplyEntity/reset> Holder<BlockPos/Entity<需判断实体类型>> <Holder/Entity> <x> <y> <z>
|
||||
// 设置对应目标的 拴绳偏移
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import net.minecraft.world.entity.Entity;
|
|||
import net.minecraft.world.entity.player.Player;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import top.r3944realms.superleadrope.api.SLPCapability;
|
||||
import top.r3944realms.superleadrope.api.type.capabilty.ILeashData;
|
||||
import top.r3944realms.superleadrope.api.type.capabilty.LeashInfo;
|
||||
|
|
@ -83,7 +84,7 @@ public final class LeashDataInnerAPI {
|
|||
* @param maxDistance the max distance
|
||||
* @return the boolean
|
||||
*/
|
||||
public static boolean attach(Entity entity, Entity holder, double maxDistance) {
|
||||
public static boolean attach(Entity entity, Entity holder, @Nullable Double maxDistance) {
|
||||
return getLeashData(entity).map(data -> data.addLeash(holder, maxDistance)).orElse(false);
|
||||
}
|
||||
|
||||
|
|
@ -93,12 +94,12 @@ public final class LeashDataInnerAPI {
|
|||
* @param entity the entity
|
||||
* @param holder the holder
|
||||
* @param maxDistance the max distance
|
||||
* @param elasticDistance the elastic distance
|
||||
* @param elasticdDistanceScale the elastic distance
|
||||
* @param maxKeepTicks the max keep ticks
|
||||
* @return the boolean
|
||||
*/
|
||||
public static boolean attach(Entity entity, Entity holder, double maxDistance, double elasticDistance, int maxKeepTicks) {
|
||||
return getLeashData(entity).map(data -> data.addLeash(holder, maxDistance, elasticDistance, maxKeepTicks)).orElse(false);
|
||||
public static boolean attach(Entity entity, Entity holder, @Nullable Double maxDistance, @Nullable Double elasticdDistanceScale, int maxKeepTicks) {
|
||||
return getLeashData(entity).map(data -> data.addLeash(holder, maxDistance, elasticdDistanceScale, maxKeepTicks)).orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -110,7 +111,7 @@ public final class LeashDataInnerAPI {
|
|||
* @param reserved the reserved
|
||||
* @return the boolean
|
||||
*/
|
||||
public static boolean attach(Entity entity, Entity holder, double maxDistance, String reserved) {
|
||||
public static boolean attach(Entity entity, Entity holder, @Nullable Double maxDistance, String reserved) {
|
||||
return getLeashData(entity).map(data -> data.addLeash(holder, maxDistance, reserved)).orElse(false);
|
||||
}
|
||||
|
||||
|
|
@ -120,13 +121,13 @@ public final class LeashDataInnerAPI {
|
|||
* @param entity the entity
|
||||
* @param holder the holder
|
||||
* @param maxDistance the max distance
|
||||
* @param elasticDistance the elastic distance
|
||||
* @param elasticDistanceScale the elastic distance
|
||||
* @param maxKeepTicks the max keep ticks
|
||||
* @param reserved the reserved
|
||||
* @return the boolean
|
||||
*/
|
||||
public static boolean attach(Entity entity, Entity holder, double maxDistance, double elasticDistance, int maxKeepTicks, String reserved) {
|
||||
return getLeashData(entity).map(data -> data.addLeash(holder, maxDistance, elasticDistance, maxKeepTicks, reserved)).orElse(false);
|
||||
public static boolean attach(Entity entity, Entity holder, @Nullable Double maxDistance, @Nullable Double elasticDistanceScale, int maxKeepTicks, String reserved) {
|
||||
return getLeashData(entity).map(data -> data.addLeash(holder, maxDistance, elasticDistanceScale, maxKeepTicks, reserved)).orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -239,10 +240,26 @@ public final class LeashDataInnerAPI {
|
|||
* @param distance the distance
|
||||
* @return the max distance
|
||||
*/
|
||||
// ---------------------- 设置最大距离 ----------------------
|
||||
public static boolean setMaxDistance(Entity entity, Entity holder, double distance) {
|
||||
// ---------------------- 设置最大距离 ----------------------
|
||||
public static boolean setMaxDistance(Entity entity, Entity holder, @Nullable Double distance) {
|
||||
return getLeashData(entity).map(data -> data.setMaxDistance(holder, distance)).orElse(false);
|
||||
}
|
||||
/**
|
||||
* Sets max distance.
|
||||
*
|
||||
* @param entity the entity
|
||||
* @param holder the holder
|
||||
* @param distance the distance
|
||||
* @return the max distance
|
||||
*/
|
||||
public static boolean setMaxDistance(Entity entity, Entity holder, @Nullable Double distance, @Nullable String reserved) {
|
||||
return getLeashData(entity)
|
||||
.map(
|
||||
data -> reserved != null ?
|
||||
data.setMaxDistance(holder, distance, reserved) :
|
||||
data.setMaxDistance(holder, distance))
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets max distance.
|
||||
|
|
@ -253,7 +270,7 @@ public final class LeashDataInnerAPI {
|
|||
* @param maxKeepTicks the max keep ticks
|
||||
* @return the max distance
|
||||
*/
|
||||
public static boolean setMaxDistance(Entity entity, Entity holder, double distance, int maxKeepTicks) {
|
||||
public static boolean setMaxDistance(Entity entity, Entity holder, @Nullable Double distance, int maxKeepTicks) {
|
||||
return getLeashData(entity).map(data -> data.setMaxDistance(holder, distance, maxKeepTicks)).orElse(false);
|
||||
}
|
||||
|
||||
|
|
@ -267,8 +284,12 @@ public final class LeashDataInnerAPI {
|
|||
* @param reserved the reserved
|
||||
* @return the max distance
|
||||
*/
|
||||
public static boolean setMaxDistance(Entity entity, Entity holder, double distance, int maxKeepTicks, String reserved) {
|
||||
return getLeashData(entity).map(data -> data.setMaxDistance(holder, distance, maxKeepTicks, reserved)).orElse(false);
|
||||
public static boolean setMaxDistance(Entity entity, Entity holder, @Nullable Double distance, int maxKeepTicks, @Nullable String reserved) {
|
||||
return getLeashData(entity)
|
||||
.map(data -> reserved != null ?
|
||||
data.setMaxDistance(holder, distance, maxKeepTicks, reserved) :
|
||||
data.setMaxDistance(holder, distance, maxKeepTicks))
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -279,7 +300,7 @@ public final class LeashDataInnerAPI {
|
|||
* @param distance the distance
|
||||
* @return the max distance
|
||||
*/
|
||||
public static boolean setMaxDistance(Entity entity, UUID holderUUID, double distance) {
|
||||
public static boolean setMaxDistance(Entity entity, UUID holderUUID, @Nullable Double distance) {
|
||||
return getLeashData(entity).map(data -> data.setMaxDistance(holderUUID, distance)).orElse(false);
|
||||
}
|
||||
|
||||
|
|
@ -292,7 +313,7 @@ public final class LeashDataInnerAPI {
|
|||
* @param maxKeepTicks the max keep ticks
|
||||
* @return the max distance
|
||||
*/
|
||||
public static boolean setMaxDistance(Entity entity, UUID holderUUID, double distance, int maxKeepTicks) {
|
||||
public static boolean setMaxDistance(Entity entity, UUID holderUUID, @Nullable Double distance, int maxKeepTicks) {
|
||||
return getLeashData(entity).map(data -> data.setMaxDistance(holderUUID, distance, maxKeepTicks)).orElse(false);
|
||||
}
|
||||
|
||||
|
|
@ -306,8 +327,14 @@ public final class LeashDataInnerAPI {
|
|||
* @param reserved the reserved
|
||||
* @return the max distance
|
||||
*/
|
||||
public static boolean setMaxDistance(Entity entity, UUID holderUUID, double distance, int maxKeepTicks, String reserved) {
|
||||
return getLeashData(entity).map(data -> data.setMaxDistance(holderUUID, distance, maxKeepTicks, reserved)).orElse(false);
|
||||
public static boolean setMaxDistance(Entity entity, UUID holderUUID, @Nullable Double distance, int maxKeepTicks,@Nullable String reserved) {
|
||||
return getLeashData(entity)
|
||||
.map(
|
||||
data -> reserved != null ?
|
||||
data.setMaxDistance(holderUUID, distance, maxKeepTicks, reserved) :
|
||||
data.setMaxDistance(holderUUID, distance, maxKeepTicks)
|
||||
)
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -318,7 +345,7 @@ public final class LeashDataInnerAPI {
|
|||
* @param distance the distance
|
||||
* @return the max distance
|
||||
*/
|
||||
public static boolean setMaxDistance(Entity entity, BlockPos knotPos, double distance) {
|
||||
public static boolean setMaxDistance(Entity entity, BlockPos knotPos, @Nullable Double distance) {
|
||||
return getLeashData(entity).map(data -> data.setMaxDistance(knotPos, distance)).orElse(false);
|
||||
}
|
||||
|
||||
|
|
@ -331,7 +358,7 @@ public final class LeashDataInnerAPI {
|
|||
* @param maxKeepTicks the max keep ticks
|
||||
* @return the max distance
|
||||
*/
|
||||
public static boolean setMaxDistance(Entity entity, BlockPos knotPos, double distance, int maxKeepTicks) {
|
||||
public static boolean setMaxDistance(Entity entity, BlockPos knotPos, @Nullable Double distance, int maxKeepTicks) {
|
||||
return getLeashData(entity).map(data -> data.setMaxDistance(knotPos, distance, maxKeepTicks)).orElse(false);
|
||||
}
|
||||
|
||||
|
|
@ -345,126 +372,150 @@ public final class LeashDataInnerAPI {
|
|||
* @param reserved the reserved
|
||||
* @return the max distance
|
||||
*/
|
||||
public static boolean setMaxDistance(Entity entity, BlockPos knotPos, double distance, int maxKeepTicks, String reserved) {
|
||||
return getLeashData(entity).map(data -> data.setMaxDistance(knotPos, distance, maxKeepTicks, reserved)).orElse(false);
|
||||
public static boolean setMaxDistance(Entity entity, BlockPos knotPos, @Nullable Double distance, int maxKeepTicks,@Nullable String reserved) {
|
||||
return getLeashData(entity)
|
||||
.map(
|
||||
data -> reserved != null ?
|
||||
data.setMaxDistance(knotPos, distance, maxKeepTicks, reserved) :
|
||||
data.setMaxDistance(knotPos, distance, maxKeepTicks)
|
||||
)
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets elastic distance.
|
||||
* Sets elastic scale.
|
||||
*
|
||||
* @param entity the entity
|
||||
* @param holder the holder
|
||||
* @param distance the distance
|
||||
* @return the elastic distance
|
||||
* @param scale the scale
|
||||
* @return the elastic scale
|
||||
*/
|
||||
// ---------------------- 设置弹性距离 ----------------------
|
||||
public static boolean setElasticDistance(Entity entity, Entity holder, double distance) {
|
||||
return getLeashData(entity).map(data -> data.setElasticDistanceScale(holder, distance)).orElse(false);
|
||||
public static boolean setElasticDistanceScale(Entity entity, Entity holder, @Nullable Double scale) {
|
||||
return getLeashData(entity).map(data -> data.setElasticDistanceScale(holder, scale)).orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets elastic distance.
|
||||
* Sets elastic scale.
|
||||
*
|
||||
* @param entity the entity
|
||||
* @param holder the holder
|
||||
* @param distance the distance
|
||||
* @param scale the scale
|
||||
* @param maxKeepTicks the max keep ticks
|
||||
* @return the elastic distance
|
||||
* @return the elastic scale
|
||||
*/
|
||||
public static boolean setElasticDistance(Entity entity, Entity holder, double distance, int maxKeepTicks) {
|
||||
return getLeashData(entity).map(data -> data.setElasticDistanceScale(holder, distance, maxKeepTicks)).orElse(false);
|
||||
public static boolean setElasticDistanceScale(Entity entity, Entity holder, @Nullable Double scale, int maxKeepTicks) {
|
||||
return getLeashData(entity).map(data -> data.setElasticDistanceScale(holder, scale, maxKeepTicks)).orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets elastic distance.
|
||||
* Sets elastic scale.
|
||||
*
|
||||
* @param entity the entity
|
||||
* @param holder the holder
|
||||
* @param distance the distance
|
||||
* @param scale the scale
|
||||
* @param maxKeepTicks the max keep ticks
|
||||
* @param reserved the reserved
|
||||
* @return the elastic distance
|
||||
* @return the elastic scale
|
||||
*/
|
||||
public static boolean setElasticDistance(Entity entity, Entity holder, double distance, int maxKeepTicks, String reserved) {
|
||||
return getLeashData(entity).map(data -> data.setElasticDistanceScale(holder, distance, maxKeepTicks, reserved)).orElse(false);
|
||||
public static boolean setElasticDistanceScale(Entity entity, Entity holder, @Nullable Double scale, int maxKeepTicks, @Nullable String reserved) {
|
||||
return getLeashData(entity)
|
||||
.map(
|
||||
data -> reserved != null ?
|
||||
data.setElasticDistanceScale(holder, scale, maxKeepTicks, reserved) :
|
||||
data.setElasticDistanceScale(holder, scale, maxKeepTicks)
|
||||
)
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets elastic distance.
|
||||
* Sets elastic scale.
|
||||
*
|
||||
* @param entity the entity
|
||||
* @param holderUUID the holder uuid
|
||||
* @param distance the distance
|
||||
* @return the elastic distance
|
||||
* @param scale the scale
|
||||
* @return the elastic scale
|
||||
*/
|
||||
public static boolean setElasticDistance(Entity entity, UUID holderUUID, double distance) {
|
||||
return getLeashData(entity).map(data -> data.setElasticDistanceScale(holderUUID, distance)).orElse(false);
|
||||
public static boolean setElasticDistanceScale(Entity entity, UUID holderUUID, @Nullable Double scale) {
|
||||
return getLeashData(entity).map(data -> data.setElasticDistanceScale(holderUUID, scale)).orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets elastic distance.
|
||||
* Sets elastic scale.
|
||||
*
|
||||
* @param entity the entity
|
||||
* @param holderUUID the holder uuid
|
||||
* @param distance the distance
|
||||
* @param scale the scale
|
||||
* @param maxKeepTicks the max keep ticks
|
||||
* @return the elastic distance
|
||||
* @return the elastic scale
|
||||
*/
|
||||
public static boolean setElasticDistance(Entity entity, UUID holderUUID, double distance, int maxKeepTicks) {
|
||||
return getLeashData(entity).map(data -> data.setElasticDistanceScale(holderUUID, distance, maxKeepTicks)).orElse(false);
|
||||
public static boolean setElasticDistanceScale(Entity entity, UUID holderUUID, @Nullable Double scale, int maxKeepTicks) {
|
||||
return getLeashData(entity).map(data -> data.setElasticDistanceScale(holderUUID, scale, maxKeepTicks)).orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets elastic distance.
|
||||
* Sets elastic scale.
|
||||
*
|
||||
* @param entity the entity
|
||||
* @param holderUUID the holder uuid
|
||||
* @param distance the distance
|
||||
* @param scale the scale
|
||||
* @param maxKeepTicks the max keep ticks
|
||||
* @param reserved the reserved
|
||||
* @return the elastic distance
|
||||
* @return the elastic scale
|
||||
*/
|
||||
public static boolean setElasticDistance(Entity entity, UUID holderUUID, double distance, int maxKeepTicks, String reserved) {
|
||||
return getLeashData(entity).map(data -> data.setElasticDistanceScale(holderUUID, distance, maxKeepTicks, reserved)).orElse(false);
|
||||
public static boolean setElasticDistanceScale(Entity entity, UUID holderUUID, @Nullable Double scale, int maxKeepTicks, @Nullable String reserved) {
|
||||
return getLeashData(entity)
|
||||
.map(
|
||||
data -> reserved != null ?
|
||||
data.setElasticDistanceScale(holderUUID, scale, maxKeepTicks, reserved) :
|
||||
data.setElasticDistanceScale(holderUUID, scale, maxKeepTicks)
|
||||
)
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets elastic distance.
|
||||
* Sets elastic scale.
|
||||
*
|
||||
* @param entity the entity
|
||||
* @param knotPos the knot pos
|
||||
* @param distance the distance
|
||||
* @return the elastic distance
|
||||
* @param scale the scale
|
||||
* @return the elastic scale
|
||||
*/
|
||||
public static boolean setElasticDistance(Entity entity, BlockPos knotPos, double distance) {
|
||||
return getLeashData(entity).map(data -> data.setElasticDistanceScale(knotPos, distance)).orElse(false);
|
||||
public static boolean setElasticDistanceScale(Entity entity, BlockPos knotPos, @Nullable Double scale) {
|
||||
return getLeashData(entity).map(data -> data.setElasticDistanceScale(knotPos, scale)).orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets elastic distance.
|
||||
* Sets elastic scale.
|
||||
*
|
||||
* @param entity the entity
|
||||
* @param knotPos the knot pos
|
||||
* @param distance the distance
|
||||
* @param scale the scale
|
||||
* @param maxKeepTicks the max keep ticks
|
||||
* @return the elastic distance
|
||||
* @return the elastic scale
|
||||
*/
|
||||
public static boolean setElasticDistance(Entity entity, BlockPos knotPos, double distance, int maxKeepTicks) {
|
||||
return getLeashData(entity).map(data -> data.setElasticDistanceScale(knotPos, distance, maxKeepTicks)).orElse(false);
|
||||
public static boolean setElasticDistanceScale(Entity entity, BlockPos knotPos, @Nullable Double scale, int maxKeepTicks) {
|
||||
return getLeashData(entity).map(data -> data.setElasticDistanceScale(knotPos, scale, maxKeepTicks)).orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets elastic distance.
|
||||
* Sets elastic scale.
|
||||
*
|
||||
* @param entity the entity
|
||||
* @param knotPos the knot pos
|
||||
* @param distance the distance
|
||||
* @param scale the scale
|
||||
* @param maxKeepTicks the max keep ticks
|
||||
* @param reserved the reserved
|
||||
* @return the elastic distance
|
||||
* @return the elastic scale
|
||||
*/
|
||||
public static boolean setElasticDistance(Entity entity, BlockPos knotPos, double distance, int maxKeepTicks, String reserved) {
|
||||
return getLeashData(entity).map(data -> data.setElasticDistanceScale(knotPos, distance, maxKeepTicks, reserved)).orElse(false);
|
||||
public static boolean setElasticDistanceScale(Entity entity, BlockPos knotPos, @Nullable Double scale, int maxKeepTicks, @Nullable String reserved) {
|
||||
return getLeashData(entity)
|
||||
.map(
|
||||
data -> reserved != null ?
|
||||
data.setElasticDistanceScale(knotPos, scale, maxKeepTicks, reserved) :
|
||||
data.setElasticDistanceScale(knotPos, scale, maxKeepTicks)
|
||||
)
|
||||
.orElse(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -515,8 +566,14 @@ public final class LeashDataInnerAPI {
|
|||
* @param reserved the reserved
|
||||
* @return the boolean
|
||||
*/
|
||||
public static boolean transfer(Entity entity, Entity holder, Entity newHolder, String reserved) {
|
||||
return getLeashData(entity).map(data -> data.transferLeash(holder, newHolder, reserved)).orElse(false);
|
||||
public static boolean transfer(Entity entity, Entity holder, Entity newHolder, @Nullable String reserved) {
|
||||
return getLeashData(entity)
|
||||
.map(
|
||||
data -> reserved != null ?
|
||||
data.transferLeash(holder, newHolder, reserved) :
|
||||
data.transferLeash(holder, newHolder)
|
||||
)
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -540,8 +597,14 @@ public final class LeashDataInnerAPI {
|
|||
* @param reserved the reserved
|
||||
* @return the boolean
|
||||
*/
|
||||
public static boolean transfer(Entity entity, UUID holderUUID, Entity newHolder, String reserved) {
|
||||
return getLeashData(entity).map(data -> data.transferLeash(holderUUID, newHolder, reserved)).orElse(false);
|
||||
public static boolean transfer(Entity entity, UUID holderUUID, Entity newHolder, @Nullable String reserved) {
|
||||
return getLeashData(entity)
|
||||
.map(
|
||||
data -> reserved != null ?
|
||||
data.transferLeash(holderUUID, newHolder, reserved) :
|
||||
data.transferLeash(holderUUID, newHolder)
|
||||
)
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -565,8 +628,14 @@ public final class LeashDataInnerAPI {
|
|||
* @param reserved the reserved
|
||||
* @return the boolean
|
||||
*/
|
||||
public static boolean transfer(Entity entity, BlockPos knotPos, Entity newHolder, String reserved) {
|
||||
return getLeashData(entity).map(data -> data.transferLeash(knotPos, newHolder, reserved)).orElse(false);
|
||||
public static boolean transfer(Entity entity, BlockPos knotPos, Entity newHolder, @Nullable String reserved) {
|
||||
return getLeashData(entity)
|
||||
.map(
|
||||
data -> reserved != null ?
|
||||
data.transferLeash(knotPos, newHolder, reserved) :
|
||||
data.transferLeash(knotPos, newHolder)
|
||||
)
|
||||
.orElse(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user