diff --git a/.gitignore b/.gitignore
index 153ecf6..d524b94 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
.gradle
+.idea
+.run
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
@@ -44,3 +46,5 @@ bin/
# Ignore Gradle build output directory
build
/RenderDoc_1.40_64/
+/.run/
+/.idea/
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 35410ca..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# 默认忽略的文件
-/shelf/
-/workspace.xml
-# 基于编辑器的 HTTP 客户端请求
-/httpRequests/
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
deleted file mode 100644
index e87ebd2..0000000
--- a/.idea/copyright/profiles_settings.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index 8567d4d..0000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index e9fc1e9..0000000
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/intellij-javadocs-4.0.1.xml b/.idea/intellij-javadocs-4.0.1.xml
deleted file mode 100644
index 6ae9a3c..0000000
--- a/.idea/intellij-javadocs-4.0.1.xml
+++ /dev/null
@@ -1,204 +0,0 @@
-
-
-
-
- UPDATE
- false
- true
-
- TYPE
- METHOD
- FIELD
-
-
- PUBLIC
- PROTECTED
- DEFAULT
-
-
-
-
-
- ^.*(public|protected|private)*.+interface\s+\w+.*
- /**\n
- * The interface ${name}.\n
-<#if element.typeParameters?has_content> * \n
-</#if>
-<#list element.typeParameters as typeParameter>
- * @param <${typeParameter.name}> the type parameter\n
-</#list>
- */
-
-
- ^.*(public|protected|private)*.+enum\s+\w+.*
- /**\n
- * The enum ${name}.\n
- */
-
-
- ^.*(public|protected|private)*.+class\s+\w+.*
- /**\n
- * The type ${name}.\n
-<#if element.typeParameters?has_content> * \n
-</#if>
-<#list element.typeParameters as typeParameter>
- * @param <${typeParameter.name}> the type parameter\n
-</#list>
- */
-
-
- .+
- /**\n
- * The type ${name}.\n
- */
-
-
-
-
- .+
- /**\n
- * Instantiates a new ${name}.\n
-<#if element.parameterList.parameters?has_content>
- *\n
-</#if>
-<#list element.parameterList.parameters as parameter>
- * @param ${parameter.name} the ${paramNames[parameter.name]}\n
-</#list>
-<#if element.throwsList.referenceElements?has_content>
- *\n
-</#if>
-<#list element.throwsList.referenceElements as exception>
- * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
-</#list>
- */
-
-
-
-
- ^.*(public|protected|private)*\s*.*(\w(\s*<.+>)*)+\s+get\w+\s*\(.*\).+
- /**\n
- * Gets ${partName}.\n
-<#if element.typeParameters?has_content> * \n
-</#if>
-<#list element.typeParameters as typeParameter>
- * @param <${typeParameter.name}> the type parameter\n
-</#list>
-<#if element.parameterList.parameters?has_content>
- *\n
-</#if>
-<#list element.parameterList.parameters as parameter>
- * @param ${parameter.name} the ${paramNames[parameter.name]}\n
-</#list>
-<#if isNotVoid>
- *\n
- * @return the ${partName}\n
-</#if>
-<#if element.throwsList.referenceElements?has_content>
- *\n
-</#if>
-<#list element.throwsList.referenceElements as exception>
- * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
-</#list>
- */
-
-
- ^.*(public|protected|private)*\s*.*(void|\w(\s*<.+>)*)+\s+set\w+\s*\(.*\).+
- /**\n
- * Sets ${partName}.\n
-<#if element.typeParameters?has_content> * \n
-</#if>
-<#list element.typeParameters as typeParameter>
- * @param <${typeParameter.name}> the type parameter\n
-</#list>
-<#if element.parameterList.parameters?has_content>
- *\n
-</#if>
-<#list element.parameterList.parameters as parameter>
- * @param ${parameter.name} the ${paramNames[parameter.name]}\n
-</#list>
-<#if isNotVoid>
- *\n
- * @return the ${partName}\n
-</#if>
-<#if element.throwsList.referenceElements?has_content>
- *\n
-</#if>
-<#list element.throwsList.referenceElements as exception>
- * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
-</#list>
- */
-
-
- ^.*((public\s+static)|(static\s+public))\s+void\s+main\s*\(\s*String\s*(\[\s*\]|\.\.\.)\s+\w+\s*\).+
- /**\n
- * The entry point of application.\n
-
- <#if element.parameterList.parameters?has_content>
- *\n
-</#if>
- * @param ${element.parameterList.parameters[0].name} the input arguments\n
-<#if element.throwsList.referenceElements?has_content>
- *\n
-</#if>
-<#list element.throwsList.referenceElements as exception>
- * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
-</#list>
- */
-
-
- .+
- /**\n
- * ${name}<#if isNotVoid> ${return}</#if>.\n
-<#if element.typeParameters?has_content> * \n
-</#if>
-<#list element.typeParameters as typeParameter>
- * @param <${typeParameter.name}> the type parameter\n
-</#list>
-<#if element.parameterList.parameters?has_content>
- *\n
-</#if>
-<#list element.parameterList.parameters as parameter>
- * @param ${parameter.name} the ${paramNames[parameter.name]}\n
-</#list>
-<#if isNotVoid>
- *\n
- * @return the ${return}\n
-</#if>
-<#if element.throwsList.referenceElements?has_content>
- *\n
-</#if>
-<#list element.throwsList.referenceElements as exception>
- * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
-</#list>
- */
-
-
-
-
- ^.*(public|protected|private)*.+static.*(\w\s\w)+.+
- /**\n
- * The constant ${element.getName()}.\n
- */
-
-
- ^.*(public|protected|private)*.*(\w\s\w)+.+
- /**\n
- <#if element.parent.isInterface()>
- * The constant ${element.getName()}.\n
-<#else>
- * The ${name}.\n
-</#if> */
-
-
- .+
- /**\n
- <#if element.parent.isEnum()>
- *${name} ${typeName}.\n
-<#else>
- * The ${name}.\n
-</#if>*/
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 1867029..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/Client.xml b/.idea/runConfigurations/Client.xml
deleted file mode 100644
index d0f88ad..0000000
--- a/.idea/runConfigurations/Client.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/RemoteDebug.run.xml b/.idea/runConfigurations/RemoteDebug.run.xml
deleted file mode 100644
index ecb2e91..0000000
--- a/.idea/runConfigurations/RemoteDebug.run.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
deleted file mode 100644
index 2b63946..0000000
--- a/.idea/uiDesigner.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.run/RemoteDebug.run.xml b/.run/RemoteDebug.run.xml
deleted file mode 100644
index 7ac6d5e..0000000
--- a/.run/RemoteDebug.run.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/java/top/r3944realms/superleadrope/CommonEventHandler.java b/src/main/java/top/r3944realms/superleadrope/CommonEventHandler.java
index b540d2b..2d17584 100644
--- a/src/main/java/top/r3944realms/superleadrope/CommonEventHandler.java
+++ b/src/main/java/top/r3944realms/superleadrope/CommonEventHandler.java
@@ -89,10 +89,25 @@ import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
+/**
+ * The type Common event handler.
+ */
public class CommonEventHandler {
+ /**
+ * The constant leashConfigManager.
+ */
public volatile static LeashConfigManager leashConfigManager;
+
+ /**
+ * The type Game.
+ */
@net.minecraftforge.fml.common.Mod.EventBusSubscriber(modid = SuperLeadRope.MOD_ID, bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.FORGE)
public static class Game {
+ /**
+ * On entity join world.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onEntityJoinWorld(EntityJoinLevelEvent event) {
Entity entity = event.getEntity();
@@ -110,6 +125,11 @@ public class CommonEventHandler {
}
}
+ /**
+ * On entity leave world.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onEntityLeaveWorld(EntityLeaveLevelEvent event) {
Entity entity = event.getEntity();
@@ -126,6 +146,12 @@ public class CommonEventHandler {
LeashStateInnerAPI.getLeashState(entity).ifPresent(LeashSyncManager.State::untrack);
}
}
+
+ /**
+ * On player logged in.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
if (!(event.getEntity() instanceof ServerPlayer player)) return; // 只处理服务端
@@ -143,6 +169,11 @@ public class CommonEventHandler {
}
}
+ /**
+ * On player right hit on block.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onPlayerRightHitOnBlock(PlayerInteractEvent.RightClickBlock event) {
Level level = event.getLevel();
@@ -159,16 +190,33 @@ public class CommonEventHandler {
}
}
+ /**
+ * Gets server level.
+ *
+ * @return the server level
+ */
public static ServerLevel getServerLevel() {
return sl;
}
private static ServerLevel sl;
+
+ /**
+ * On server starting.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onServerStarting(ServerStartingEvent event) {
PotatoMode mode = PotatoModeHelper.getCurrentMode();
EternalPotatoFacade.init(mode, true); // 服务端
}
+
+ /**
+ * On world load.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onWorldLoad(LevelEvent.Load event) {
if (event.getLevel() instanceof ServerLevel serverLevel) {
@@ -181,6 +229,11 @@ public class CommonEventHandler {
}
}
+ /**
+ * On world unload.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onWorldUnload(LevelEvent.Unload event) {
if (event.getLevel() instanceof ServerLevel serverLevel) {
@@ -192,11 +245,22 @@ public class CommonEventHandler {
}
}
- // 服务器关闭
+ /**
+ * On server stopping.
+ *
+ * @param event the event
+ */
+// 服务器关闭
@SubscribeEvent
public static void onServerStopping(ServerStoppingEvent event) {
EternalPotatoFacade.clear();
}
+
+ /**
+ * On item drop.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onItemDrop(ItemTossEvent event) {
Player player = event.getPlayer();
@@ -231,6 +295,12 @@ public class CommonEventHandler {
);
}
}
+
+ /**
+ * On item pickup.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onItemPickup(@NotNull PlayerEvent.ItemPickupEvent event) {
Player player = event.getEntity();
@@ -256,6 +326,11 @@ public class CommonEventHandler {
}
}
+ /**
+ * On entity teleport.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onEntityTeleport(EntityTeleportEvent event) {
Entity telEntity = event.getEntity();
@@ -326,11 +401,23 @@ public class CommonEventHandler {
RidingApplier.applyRidingRelationship(filteredRelationship, serverLevel::getEntity);
}
}
+
+ /**
+ * On player clone.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onPlayerClone(PlayerEvent.Clone event) {
CapabilityRemainder.onPlayerClone(event);
}
private static int tickCounter = 0;
+
+ /**
+ * On server tick.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onServerTick(TickEvent.ServerTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
@@ -350,42 +437,92 @@ public class CommonEventHandler {
LeashSyncManager.Data.forEach(ILeashData::applyLeashForces);
}
}
+
+ /**
+ * On entity attack.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onEntityAttack (AttackEntityEvent event) {
LeashInteractHandler.onEntityLeftInteract(event.getEntity().level(), event.getTarget(), event.getEntity(), event);
}
+
+ /**
+ * On entity interact.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onEntityInteract (PlayerInteractEvent.EntityInteract event) {
LeashInteractHandler.onEntityRightInteract(event.getLevel(), event.getHand(), event.getTarget(), event.getEntity(), event); //处理实体互动
}
+ /**
+ * Attach capability.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void attachCapability(AttachCapabilitiesEvent> event) {
CapabilityHandler.attachCapability(event);
}
+
+ /**
+ * On register command.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onRegisterCommand (RegisterCommandsEvent event) {
CommandDispatcher dispatcher = event.getDispatcher();
MotionCommand.register(dispatcher);
}
}
+
+ /**
+ * The type Mod.
+ */
@net.minecraftforge.fml.common.Mod.EventBusSubscriber(modid = SuperLeadRope.MOD_ID, bus= net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD)
public static class Mod {
+ /**
+ * On fml common init.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onFMLCommonInit(FMLCommonSetupEvent event) {
event.enqueueWork(Mod::checkAndSet);
event.enqueueWork(SLPGameruleRegistry::register);//规则注册
}
+
+ /**
+ * Register capability.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void registerCapability(RegisterCapabilitiesEvent event) {
CapabilityHandler.registerCapability(event);
}
+
+ /**
+ * On creative tab.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onCreativeTab (BuildCreativeModeTabContentsEvent event) {
if (event.getTabKey() == CreativeModeTabs.TOOLS_AND_UTILITIES) {
event.accept(SLPItems.SUPER_LEAD_ROPE);
}
}
+
+ /**
+ * On config reloading.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public void onConfigReloading(ModConfigEvent.Reloading event) {
if (event.getConfig().getSpec() == LeashCommonConfig.SPEC) {
@@ -402,6 +539,11 @@ public class CommonEventHandler {
}
}
+ /**
+ * On config loaded.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public void onConfigLoaded(ModConfigEvent.Loading event) {
if (event.getConfig().getSpec() == LeashCommonConfig.SPEC) {
@@ -410,6 +552,11 @@ public class CommonEventHandler {
}
}
+ /**
+ * On config reloaded.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public void onConfigReloaded(ModConfigEvent.Reloading event) {
if (event.getConfig().getSpec() == LeashCommonConfig.SPEC) {
@@ -418,6 +565,11 @@ public class CommonEventHandler {
}
}
+ /**
+ * On config unloaded.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public void onConfigUnloaded(ModConfigEvent.Unloading event) {
if (event.getConfig().getSpec() == LeashCommonConfig.SPEC) {
diff --git a/src/main/java/top/r3944realms/superleadrope/SuperLeadRope.java b/src/main/java/top/r3944realms/superleadrope/SuperLeadRope.java
index 2ccee29..0f9c470 100644
--- a/src/main/java/top/r3944realms/superleadrope/SuperLeadRope.java
+++ b/src/main/java/top/r3944realms/superleadrope/SuperLeadRope.java
@@ -30,12 +30,25 @@ import top.r3944realms.superleadrope.core.register.SLPSoundEvents;
import top.r3944realms.superleadrope.network.NetworkHandler;
import top.r3944realms.superleadrope.util.file.ConfigUtil;
+/**
+ * The type Super lead rope.
+ */
@Mod(value = SuperLeadRope.MOD_ID)
//TODO: API规范化
public class SuperLeadRope {
+ /**
+ * The constant logger.
+ */
public static final Logger logger = LoggerFactory.getLogger(SuperLeadRope.class);
+ /**
+ * The constant MOD_ID.
+ */
public static final String MOD_ID = "superleadrope";
+
+ /**
+ * Instantiates a new Super lead rope.
+ */
public SuperLeadRope() {
IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
SLPItems.register(eventBus);
@@ -45,6 +58,10 @@ public class SuperLeadRope {
initialize();
}
+
+ /**
+ * Initialize.
+ */
public static void initialize() {
logger.info("Initializing SuperLeadRope");
String c = "common";
@@ -53,7 +70,13 @@ public class SuperLeadRope {
ConfigUtil.registerConfig(modLoadingContext, ModConfig.Type.COMMON, LeashCommonConfig.SPEC, c, "leash");
}
+ /**
+ * The type Mod info.
+ */
public static class ModInfo {
+ /**
+ * The constant VERSION.
+ */
public static final String VERSION;
static {
// 从 ModList 获取当前 ModContainer 的元数据
diff --git a/src/main/java/top/r3944realms/superleadrope/api/SLPCapability.java b/src/main/java/top/r3944realms/superleadrope/api/SLPCapability.java
index f7fb229..7b16f36 100644
--- a/src/main/java/top/r3944realms/superleadrope/api/SLPCapability.java
+++ b/src/main/java/top/r3944realms/superleadrope/api/SLPCapability.java
@@ -21,7 +21,16 @@ import net.minecraftforge.common.capabilities.CapabilityToken;
import top.r3944realms.superleadrope.api.type.capabilty.ILeashData;
import top.r3944realms.superleadrope.api.type.capabilty.ILeashState;
+/**
+ * The type Slp capability.
+ */
public class SLPCapability {
+ /**
+ * The constant LEASH_DATA_CAP.
+ */
public static final Capability LEASH_DATA_CAP = CapabilityManager.get(new CapabilityToken<>(){});
+ /**
+ * The constant LEASH_STATE_CAP.
+ */
public static final Capability LEASH_STATE_CAP = CapabilityManager.get(new CapabilityToken<>() {});
}
diff --git a/src/main/java/top/r3944realms/superleadrope/api/SuperLeadRopeApi.java b/src/main/java/top/r3944realms/superleadrope/api/SuperLeadRopeApi.java
index 0c8d18b..f29679b 100644
--- a/src/main/java/top/r3944realms/superleadrope/api/SuperLeadRopeApi.java
+++ b/src/main/java/top/r3944realms/superleadrope/api/SuperLeadRopeApi.java
@@ -18,64 +18,201 @@ package top.r3944realms.superleadrope.api;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
+import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import top.r3944realms.superleadrope.api.type.capabilty.ILeashData;
+import top.r3944realms.superleadrope.api.type.capabilty.ILeashState;
import top.r3944realms.superleadrope.api.type.util.ILeashHelper;
import top.r3944realms.superleadrope.api.workspace.Services;
import java.util.List;
+import java.util.Optional;
import java.util.UUID;
import java.util.function.Predicate;
+/**
+ * The type Super lead rope api.
+ */
@SuppressWarnings("unused")
public class SuperLeadRopeApi {
+ /**
+ * The constant LOGGER.
+ */
public static final Logger LOGGER = LoggerFactory.getLogger(SuperLeadRopeApi.class);
+ /**
+ * The constant MOD_ID.
+ */
public static String MOD_ID = "superleadrope";
+
+ /**
+ * Gets leash helper.
+ *
+ * @return the leash helper
+ */
public static ILeashHelper getLeashHelper() {
return Services.WORK_SPACE.getLeashHelper();
}
+
+ /**
+ * Leashable in area list.
+ *
+ * @param pLevel the p level
+ * @param pPos the p pos
+ * @param filter the filter
+ * @return the list
+ */
public static @NotNull List leashableInArea(Level pLevel, Vec3 pPos, Predicate filter) {
return leashableInArea(pLevel, pPos, filter, 1024D);
}
+
+ /**
+ * Leashable in area list.
+ *
+ * @param entity the entity
+ * @param filter the filter
+ * @param fetchDistance the fetch distance
+ * @return the list
+ */
public static @NotNull List leashableInArea(@NotNull Entity entity, Predicate filter, double fetchDistance) {
return leashableInArea(entity.level(), entity.getBoundingBox().getCenter(), filter, fetchDistance);
}
+
+ /**
+ * Leashable in area list.
+ *
+ * @param pLevel the p level
+ * @param pPos the p pos
+ * @param filter the filter
+ * @param fetchDistance the fetch distance
+ * @return the list
+ */
public static @NotNull List leashableInArea(@NotNull Level pLevel, Vec3 pPos, Predicate filter, double fetchDistance) {
return Services.WORK_SPACE.leashableInArea(pLevel, pPos, filter, fetchDistance);
}
+
+ /**
+ * Leashable in area list.
+ *
+ * @param entity the entity
+ * @param filter the filter
+ * @return the list
+ */
public static @NotNull List leashableInArea(Entity entity, Predicate filter) {
return leashableInArea(entity, filter, 1024D);
}
+
+ /**
+ * Leashable in area list.
+ *
+ * @param holder the holder
+ * @return the list
+ */
public static @NotNull List leashableInArea(Entity holder) {
return leashableInArea(holder, i -> isLeashHolder(i, holder), 1024D);
}
+
+ /**
+ * Leashable in area list.
+ *
+ * @param holder the holder
+ * @param clazz the clazz
+ * @param box the box
+ * @param filter the filter
+ * @return the list
+ */
+ public static @NotNull List leashableInArea(Entity holder, Class clazz, AABB box, Predicate filter) {
+ return Services.WORK_SPACE.leashableInArea(holder.level(), clazz, i -> isLeashHolder(i, holder), box);
+ }
+
+ /**
+ * Is super lead knot boolean.
+ *
+ * @param entity the entity
+ * @return the boolean
+ */
public static boolean isSuperLeadKnot(Entity entity) {
return Services.WORK_SPACE.isSuperLeadKnot(entity);
}
+
+ /**
+ * Gets super lead knot pos.
+ *
+ * @param entity the entity
+ * @return the super lead knot pos
+ */
public static BlockPos getSuperLeadKnotPos(Entity entity) {
return Services.WORK_SPACE.getSuperLeadPos(entity);
}
+
+ /**
+ * Is leashable boolean.
+ *
+ * @param entity the entity
+ * @return the boolean
+ */
public static boolean isLeashable(Entity entity) {
return Services.WORK_SPACE.isLeashable(entity);
}
+ /**
+ * Is leash holder boolean.
+ *
+ * @param pEntity the p entity
+ * @param pTestHolder the p test holder
+ * @return the boolean
+ */
public static boolean isLeashHolder(@NotNull Entity pEntity, Entity pTestHolder) {
return Services.WORK_SPACE.isSuperLeadKnot(pTestHolder) ?
isLeashHolder(pEntity, Services.WORK_SPACE.getSuperLeadPos(pTestHolder)) :
isLeashHolder(pEntity, pTestHolder.getUUID());
}
+ /**
+ * Is leash holder boolean.
+ *
+ * @param pEntity the p entity
+ * @param pHolderUUID the p holder uuid
+ * @return the boolean
+ */
public static boolean isLeashHolder(@NotNull Entity pEntity, UUID pHolderUUID) {
return Services.WORK_SPACE.getLeashData(pEntity)
.map(leashData -> leashData.isLeashedBy(pHolderUUID))
.orElse(false);
}
+ /**
+ * Is leash holder boolean.
+ *
+ * @param pEntity the p entity
+ * @param pKnotPos the p knot pos
+ * @return the boolean
+ */
public static boolean isLeashHolder(@NotNull Entity pEntity, BlockPos pKnotPos) {
return Services.WORK_SPACE.getLeashData(pEntity)
.map(leashData -> leashData.isLeashedBy(pKnotPos))
.orElse(false);
}
+
+ /**
+ * Gets leash state.
+ *
+ * @param pEntity the p entity
+ * @return the leash state
+ */
+ public static Optional getLeashState(Entity pEntity) {
+ return Services.WORK_SPACE.getLeashState(pEntity);
+ }
+
+ /**
+ * Gets leash data.
+ *
+ * @param pEntity the p entity
+ * @return the leash data
+ */
+ public static Optional getLeashData(Entity pEntity) {
+ return Services.WORK_SPACE.getLeashData(pEntity);
+ }
}
diff --git a/src/main/java/top/r3944realms/superleadrope/api/event/SuperLeadRopeEvent.java b/src/main/java/top/r3944realms/superleadrope/api/event/SuperLeadRopeEvent.java
index 53a26a7..8668d9a 100644
--- a/src/main/java/top/r3944realms/superleadrope/api/event/SuperLeadRopeEvent.java
+++ b/src/main/java/top/r3944realms/superleadrope/api/event/SuperLeadRopeEvent.java
@@ -30,18 +30,35 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+/**
+ * The type Super lead rope event.
+ */
@SuppressWarnings("unused")
public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
private final Entity LeashedEntity;
+ /**
+ * Instantiates a new Super lead rope event.
+ *
+ * @param leashedEntity the leashed entity
+ */
protected SuperLeadRopeEvent(Entity leashedEntity) {
LeashedEntity = leashedEntity;
}
+ /**
+ * Gets leashed entity.
+ *
+ * @return the leashed entity
+ */
public Entity getLeashedEntity() {
return LeashedEntity;
}
- // ADD LEASH
+
+ /**
+ * The type Add leash.
+ */
+// ADD LEASH
@SuppressWarnings("unused")
@Cancelable
public static class AddLeash extends SuperLeadRopeEvent {
@@ -50,33 +67,85 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
private final Double maxLeashDistance;
@Nullable
private final Double elasticDistanceScale;
+
+ /**
+ * Instantiates a new Add leash.
+ *
+ * @param leashedEntity the leashed entity
+ * @param holderEntity the holder entity
+ */
public AddLeash(Entity leashedEntity, Entity holderEntity) {
this(leashedEntity, holderEntity, null, null);
}
+
+ /**
+ * Instantiates a new Add leash.
+ *
+ * @param leashedEntity the leashed entity
+ * @param holderEntity the holder entity
+ * @param maxLeashDistance the max leash distance
+ * @param elasticDistanceScale the elastic distance scale
+ */
public AddLeash(Entity leashedEntity, Entity holderEntity, @Nullable Double maxLeashDistance, @Nullable Double elasticDistanceScale) {
super(leashedEntity);
this.holderEntity = holderEntity;
this.maxLeashDistance = maxLeashDistance;
this.elasticDistanceScale = elasticDistanceScale;
}
+
+ /**
+ * Gets holder entity.
+ *
+ * @return the holder entity
+ */
public Entity getHolderEntity() {
return holderEntity;
}
+
+ /**
+ * Gets max leash distance.
+ *
+ * @return the max leash distance
+ */
public @Nullable Double getMaxLeashDistance() {
return maxLeashDistance;
}
+
+ /**
+ * Gets elastic distance scale.
+ *
+ * @return the elastic distance scale
+ */
public @Nullable Double getElasticDistanceScale() {
return elasticDistanceScale;
}
}
- // REMOVE LEASH
+
+ /**
+ * The type Remove leash.
+ */
+// REMOVE LEASH
@SuppressWarnings("unused")
@Cancelable
public static class RemoveLeash extends SuperLeadRopeEvent {
private final LeashHolder leashHolder;
+
+ /**
+ * Instantiates a new Remove leash.
+ *
+ * @param leashedEntity the leashed entity
+ * @param holderEntity the holder entity
+ */
public RemoveLeash(Entity leashedEntity, UUID holderEntity) {
this(leashedEntity, holderEntity, null, false);
}
+
+ /**
+ * Instantiates a new Remove leash.
+ *
+ * @param leashedEntity the leashed entity
+ * @param holderKnot the holder knot
+ */
public RemoveLeash(Entity leashedEntity, BlockPos holderKnot) {
this(leashedEntity, null, holderKnot, true);
}
@@ -86,20 +155,45 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
leashHolder = new LeashHolder(holderPos);
} else leashHolder = new LeashHolder(holderEntity);
}
+
+ /**
+ * Gets leash holder.
+ *
+ * @return the leash holder
+ */
public LeashHolder getLeashHolder() {
return leashHolder;
}
}
- // TRANSFORM LEASH
+ /**
+ * The type Transfer leash.
+ */
+// TRANSFORM LEASH
@SuppressWarnings("unused")
@Cancelable
public static class TransferLeash extends SuperLeadRopeEvent {
private final LeashHolder oldLeashHolder;
private final Entity newLeashHolder;
+
+ /**
+ * Instantiates a new Transfer leash.
+ *
+ * @param leashedEntity the leashed entity
+ * @param holderEntity the holder entity
+ * @param newLeashHolder the new leash holder
+ */
public TransferLeash(Entity leashedEntity, UUID holderEntity, Entity newLeashHolder) {
this(leashedEntity, holderEntity, null, false , newLeashHolder);
}
+
+ /**
+ * Instantiates a new Transfer leash.
+ *
+ * @param leashedEntity the leashed entity
+ * @param holderKnot the holder knot
+ * @param newLeashHolder the new leash holder
+ */
public TransferLeash(Entity leashedEntity, BlockPos holderKnot, Entity newLeashHolder) {
this(leashedEntity, null, holderKnot, true, newLeashHolder);
}
@@ -111,16 +205,29 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
this.newLeashHolder = newLeashHolder;
}
+ /**
+ * Gets new leash holder.
+ *
+ * @return the new leash holder
+ */
public Entity getNewLeashHolder() {
return newLeashHolder;
}
+ /**
+ * Gets old leash holder.
+ *
+ * @return the old leash holder
+ */
public LeashHolder getOldLeashHolder() {
return oldLeashHolder;
}
}
- // MODIFY LEASH MAX_LEASH_LENGTH / ELASTIC_DISTANCE_SCALE
+ /**
+ * The type Modify value.
+ */
+// MODIFY LEASH MAX_LEASH_LENGTH / ELASTIC_DISTANCE_SCALE
@SuppressWarnings("unused")
@Cancelable
public static class ModifyValue extends SuperLeadRopeEvent {
@@ -132,14 +239,44 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
private final Double newValue;
private final Type type;
private final Scope scope;
+
+ /**
+ * The enum Type.
+ */
public enum Type {
+ /**
+ * Max distance type.
+ */
MAX_DISTANCE,
+ /**
+ * Elastic distance scale type.
+ */
ELASTIC_DISTANCE_SCALE,
}
+
+ /**
+ * The enum Scope.
+ */
public enum Scope {
+ /**
+ * Static scope.
+ */
STATIC,
+ /**
+ * Instance scope.
+ */
INSTANCE
}
+
+ /**
+ * 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
+ */
public ModifyValue(Entity leashedEntity, UUID holderUUID, @Nullable Double oldValue, @Nullable Double newValue, Type type) {
super(leashedEntity);
this.holder = new LeashHolder(holderUUID);
@@ -148,6 +285,16 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
this.type = type;
this.scope = Scope.INSTANCE;
}
+
+ /**
+ * 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
+ */
public ModifyValue(Entity leashedEntity, BlockPos knotBlockpos, @Nullable Double oldValue, @Nullable Double newValue, Type type) {
super(leashedEntity);
this.holder = new LeashHolder(knotBlockpos);
@@ -156,6 +303,15 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
this.type = type;
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 Double oldValue, @Nullable Double newValue, Type type) {
super(leashedEntity);
this.holder = null;
@@ -164,29 +320,58 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
this.type = type;
this.scope = Scope.STATIC;
}
+
+ /**
+ * Gets holder.
+ *
+ * @return the holder
+ */
public @Nullable LeashHolder getHolder() {
return holder;
}
+ /**
+ * Gets old value.
+ *
+ * @return the old value
+ */
public @Nullable Double getOldValue() {
return oldValue;
}
+ /**
+ * Gets new value.
+ *
+ * @return the new value
+ */
public @Nullable Double getNewValue() {
return newValue;
}
+ /**
+ * Gets type.
+ *
+ * @return the type
+ */
public Type getType() {
return type;
}
+ /**
+ * Gets scope.
+ *
+ * @return the scope
+ */
public Scope getScope() {
return scope;
}
}
- // HAS FOCUS
+ /**
+ * The type Has focus.
+ */
+// HAS FOCUS
@SuppressWarnings("unused")
@Cancelable
public static class hasFocus extends SuperLeadRopeEvent {
@@ -194,6 +379,16 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
private final Map vaildLeashKnots;
private final Entity finalForceTarget;
private Vec3 combinedForce;
+
+ /**
+ * Instantiates a new Has focus.
+ *
+ * @param leashedEntity the leashed entity
+ * @param finalForceTarget the final force target
+ * @param combinedForce the combined force
+ * @param vaildLeashHolders the vaild leash holders
+ * @param vaildLeashKnots the vaild leash knots
+ */
public hasFocus(Entity leashedEntity, Entity finalForceTarget, Vec3 combinedForce, Map vaildLeashHolders, Map vaildLeashKnots) {
super(leashedEntity);
this.finalForceTarget = finalForceTarget;
@@ -202,58 +397,134 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
this.vaildLeashKnots = new HashMap<>(vaildLeashKnots);
}
+ /**
+ * Gets final force target.
+ *
+ * @return the final force target
+ */
public Entity getFinalForceTarget() {
return finalForceTarget;
}
+
+ /**
+ * Gets combined force.
+ *
+ * @return the combined force
+ */
public Vec3 getCombinedForce() {
return combinedForce;
}
+ /**
+ * Sets combined force.
+ *
+ * @param combinedForce the combined force
+ */
public void setCombinedForce(Vec3 combinedForce) {
this.combinedForce = combinedForce;
}
+
+ /**
+ * Gets vaild leash holders.
+ *
+ * @return the vaild leash holders
+ */
public Map getVaildLeashHolders() {
return vaildLeashHolders;
}
+ /**
+ * Gets vaild leash knots.
+ *
+ * @return the vaild leash knots
+ */
public Map getVaildLeashKnots() {
return vaildLeashKnots;
}
}
- // KEEP NOT BREAK TICK
+ /**
+ * The type Keep not break tick.
+ */
+// KEEP NOT BREAK TICK
@SuppressWarnings("unused")
public static class keepNotBreakTick extends SuperLeadRopeEvent {
private final int remainedTicks;
private final Entity holderEntity;
private final Map.Entry, LeashInfo> entry;
+
+ /**
+ * Instantiates a new Keep not break tick.
+ *
+ * @param leashedEntity the leashed entity
+ * @param remainedTicks the remained ticks
+ * @param holderEntity the holder entity
+ * @param entry the entry
+ */
public keepNotBreakTick(Entity leashedEntity, int remainedTicks, Entity holderEntity, Map.Entry, LeashInfo> entry) {
super(leashedEntity);
this.remainedTicks = remainedTicks;
this.holderEntity = holderEntity;
this.entry = entry;
}
+
+ /**
+ * Gets holder entity.
+ *
+ * @return the holder entity
+ */
public Entity getHolderEntity() {
return holderEntity;
}
+
+ /**
+ * Gets remained ticks.
+ *
+ * @return the remained ticks
+ */
public int getRemainedTicks() {
return remainedTicks;
}
+
+ /**
+ * Reset remained ticks.
+ */
public void resetRemainedTicks() {
entry.setValue(entry.getValue().resetKeepTicks());
}
+
+ /**
+ * Gets max keep ticks.
+ *
+ * @return the max keep ticks
+ */
public int getMaxKeepTicks() {
return entry.getValue().maxKeepLeashTicks();
}
}
- // TELEPORT
+
+ /**
+ * The type Teleport with holder.
+ */
+// TELEPORT
@Cancelable
@SuppressWarnings("unused")
public static class teleportWithHolder extends SuperLeadRopeEvent {
private final Entity holderEntity;
private final Level originalLevel, newLevel;
private final Vec3 originalPosition, newPosition;
+
+ /**
+ * Instantiates a new Teleport with holder.
+ *
+ * @param leashedEntity the leashed entity
+ * @param holderEntity the holder entity
+ * @param originalLevel the original level
+ * @param newLevel the new level
+ * @param originalPosition the original position
+ * @param newPosition the new position
+ */
public teleportWithHolder(Entity leashedEntity, Entity holderEntity, Level originalLevel, Level newLevel, Vec3 originalPosition, Vec3 newPosition) {
super(leashedEntity);
this.holderEntity = holderEntity;
@@ -262,21 +533,48 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
this.originalPosition = originalPosition;
this.newPosition = newPosition;
}
+
+ /**
+ * Gets holder entity.
+ *
+ * @return the holder entity
+ */
public Entity getHolderEntity() {
return holderEntity;
}
+
+ /**
+ * Gets original position.
+ *
+ * @return the original position
+ */
public Vec3 getOriginalPosition() {
return originalPosition;
}
+ /**
+ * Gets original level.
+ *
+ * @return the original level
+ */
public Level getOriginalLevel() {
return originalLevel;
}
+ /**
+ * Gets new level.
+ *
+ * @return the new level
+ */
public Level getNewLevel() {
return newLevel;
}
+ /**
+ * Gets new position.
+ *
+ * @return the new position
+ */
public Vec3 getNewPosition() {
return newPosition;
}
diff --git a/src/main/java/top/r3944realms/superleadrope/api/type/capabilty/ILeashData.java b/src/main/java/top/r3944realms/superleadrope/api/type/capabilty/ILeashData.java
index 78fc785..bab478c 100644
--- a/src/main/java/top/r3944realms/superleadrope/api/type/capabilty/ILeashData.java
+++ b/src/main/java/top/r3944realms/superleadrope/api/type/capabilty/ILeashData.java
@@ -30,122 +30,609 @@ import java.util.UUID;
*/
@SuppressWarnings("unused")
public interface ILeashData extends INBTSerializable {
+ /**
+ * Self entity.
+ *
+ * @return the entity
+ */
+ Entity self();
+
+ /**
+ * Gets static max distance.
+ *
+ * @return the static max distance
+ */
Double getStaticMaxDistance();
+
+ /**
+ * Sets static max distance.
+ *
+ * @param distance the distance
+ */
void setStaticMaxDistance(Double distance);
+
+ /**
+ * Gets default max distance.
+ *
+ * @return the default max distance
+ */
double getDefaultMaxDistance();
+
+ /**
+ * Gets current max distance.
+ *
+ * @return the current max distance
+ */
double getCurrentMaxDistance();
+
+ /**
+ * Update all max distance.
+ */
void updateAllMaxDistance();
+
+ /**
+ * Gets static elastic distance scale.
+ *
+ * @return the static elastic distance scale
+ */
Double getStaticElasticDistanceScale();
+
+ /**
+ * Sets static elastic distance scale.
+ *
+ * @param distance the distance
+ */
void setStaticElasticDistanceScale(Double distance);
+
+ /**
+ * Gets default elastic distance scale.
+ *
+ * @return the default elastic distance scale
+ */
double getDefaultElasticDistanceScale();
+
+ /**
+ * Gets current elastic distance scale.
+ *
+ * @return the current elastic distance scale
+ */
double getCurrentElasticDistanceScale();
+
+ /**
+ * Update all elastic distance scale.
+ */
void updateAllElasticDistanceScale();
+
+ /**
+ * Update all.
+ */
default void updateAll() {
updateAllMaxDistance();
updateAllElasticDistanceScale();
}
+
+ /**
+ * Add leash boolean.
+ *
+ * @param holder the holder
+ * @return the boolean
+ */
/* ----------------------
* Add / removeApplyEntity leashes
* ---------------------- */
boolean addLeash(Entity holder);
+
+ /**
+ * Add leash boolean.
+ *
+ * @param holder the holder
+ * @param reserved the reserved
+ * @return the boolean
+ */
boolean addLeash(Entity holder, String reserved);
+
+ /**
+ * Add leash boolean.
+ *
+ * @param holder the holder
+ * @param maxDistance the max distance
+ * @return the boolean
+ */
boolean addLeash(Entity holder, Double maxDistance);
+
+ /**
+ * Add leash boolean.
+ *
+ * @param holder the holder
+ * @param maxDistance the max distance
+ * @param elasticDistanceScale the elastic distance scale
+ * @return the boolean
+ */
boolean addLeash(Entity holder, Double maxDistance, Double elasticDistanceScale);
+
+ /**
+ * Add leash boolean.
+ *
+ * @param holder the holder
+ * @param maxDistance the max distance
+ * @param elasticDistanceScale the elastic distance scale
+ * @param maxKeepTicks the max keep ticks
+ * @return the boolean
+ */
boolean addLeash(Entity holder, Double maxDistance, Double elasticDistanceScale, int maxKeepTicks);
+
+ /**
+ * Add leash boolean.
+ *
+ * @param holder the holder
+ * @param maxDistance the max distance
+ * @param elasticDistanceScale the elastic distance scale
+ * @param reserved the reserved
+ * @return the boolean
+ */
boolean addLeash(Entity holder, Double maxDistance, Double elasticDistanceScale, String reserved);
+
+ /**
+ * Add leash boolean.
+ *
+ * @param holder the holder
+ * @param maxDistance the max distance
+ * @param reserved the reserved
+ * @return the boolean
+ */
boolean addLeash(Entity holder, Double maxDistance, String reserved);
+
+ /**
+ * Add leash boolean.
+ *
+ * @param holder the holder
+ * @param maxDistance the max distance
+ * @param elasticDistanceScale the elastic distance scale
+ * @param maxKeepTicks the max keep ticks
+ * @param reserved the reserved
+ * @return the boolean
+ */
boolean addLeash(Entity holder, Double maxDistance, Double elasticDistanceScale, int maxKeepTicks, String reserved);
+ /**
+ * Add leash.
+ *
+ * @param holder the holder
+ * @param info the info
+ */
void addLeash(Entity holder, LeashInfo info);
+ /**
+ * Add delayed leash.
+ *
+ * @param holderPlayer the holder player
+ */
void addDelayedLeash(Player holderPlayer);
+
+ /**
+ * Remove delayed leash.
+ *
+ * @param onceHolderPlayerUUID the once holder player uuid
+ */
void removeDelayedLeash(UUID onceHolderPlayerUUID);
+ /**
+ * Remove leash boolean.
+ *
+ * @param holder the holder
+ * @return the boolean
+ */
boolean removeLeash(Entity holder);
+
+ /**
+ * Remove leash boolean.
+ *
+ * @param holderUUID the holder uuid
+ * @return the boolean
+ */
boolean removeLeash(UUID holderUUID);
+
+ /**
+ * Remove leash boolean.
+ *
+ * @param knotPos the knot pos
+ * @return the boolean
+ */
boolean removeLeash(BlockPos knotPos);
+ /**
+ * Remove all leashes.
+ */
void removeAllLeashes();
+
+ /**
+ * Remove all holder leashes.
+ */
void removeAllHolderLeashes();
+
+ /**
+ * Remove all knot leashes.
+ */
void removeAllKnotLeashes();
+ /**
+ * Sets max distance.
+ *
+ * @param holder the holder
+ * @param distance the distance
+ * @return the max distance
+ */
/* ----------------------
* Modify leash properties
* ---------------------- */
boolean setMaxDistance(Entity holder, Double distance);
+
+ /**
+ * Sets max distance.
+ *
+ * @param holder the holder
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @return the max distance
+ */
boolean setMaxDistance(Entity holder, Double distance, int maxKeepTicks);
+
+ /**
+ * Sets max distance.
+ *
+ * @param holder the holder
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @param reserved the reserved
+ * @return the max distance
+ */
boolean setMaxDistance(Entity holder, Double distance, int maxKeepTicks, String reserved);
+ /**
+ * Sets max distance.
+ *
+ * @param holderUUID the holder uuid
+ * @param distance the distance
+ * @return the max distance
+ */
boolean setMaxDistance(UUID holderUUID, Double distance);
+
+ /**
+ * Sets max distance.
+ *
+ * @param holderUUID the holder uuid
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @return the max distance
+ */
boolean setMaxDistance(UUID holderUUID, Double distance, int maxKeepTicks);
+
+ /**
+ * Sets max distance.
+ *
+ * @param holderUUID the holder uuid
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @param reserved the reserved
+ * @return the max distance
+ */
boolean setMaxDistance(UUID holderUUID, Double distance, int maxKeepTicks, String reserved);
+ /**
+ * Sets max distance.
+ *
+ * @param knotPos the knot pos
+ * @param distance the distance
+ * @return the max distance
+ */
boolean setMaxDistance(BlockPos knotPos, Double distance);
+
+ /**
+ * Sets max distance.
+ *
+ * @param knotPos the knot pos
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @return the max distance
+ */
boolean setMaxDistance(BlockPos knotPos, Double distance, int maxKeepTicks);
+
+ /**
+ * Sets max distance.
+ *
+ * @param knotPos the knot pos
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @param reserved the reserved
+ * @return the max distance
+ */
boolean setMaxDistance(BlockPos knotPos, Double distance, int maxKeepTicks, String reserved);
+ /**
+ * Sets elastic distance scale.
+ *
+ * @param holder the holder
+ * @param scale the scale
+ * @return the elastic distance scale
+ */
boolean setElasticDistanceScale(Entity holder, Double scale);
+
+ /**
+ * Sets elastic distance scale.
+ *
+ * @param holder the holder
+ * @param scale the scale
+ * @param maxKeepTicks the max keep ticks
+ * @return the elastic distance scale
+ */
boolean setElasticDistanceScale(Entity holder, Double scale, int maxKeepTicks);
+
+ /**
+ * Sets elastic distance scale.
+ *
+ * @param holder the holder
+ * @param scale the scale
+ * @param maxKeepTicks the max keep ticks
+ * @param reserved the reserved
+ * @return the elastic distance scale
+ */
boolean setElasticDistanceScale(Entity holder, Double scale, int maxKeepTicks, String reserved);
+ /**
+ * Sets elastic distance scale.
+ *
+ * @param holderUUID the holder uuid
+ * @param scale the scale
+ * @return the elastic distance scale
+ */
boolean setElasticDistanceScale(UUID holderUUID, Double scale);
+
+ /**
+ * Sets elastic distance scale.
+ *
+ * @param holderUUID the holder uuid
+ * @param scale the scale
+ * @param maxKeepTicks the max keep ticks
+ * @return the elastic distance scale
+ */
boolean setElasticDistanceScale(UUID holderUUID, Double scale, int maxKeepTicks);
+
+ /**
+ * Sets elastic distance scale.
+ *
+ * @param holderUUID the holder uuid
+ * @param scale the scale
+ * @param maxKeepTicks the max keep ticks
+ * @param reserved the reserved
+ * @return the elastic distance scale
+ */
boolean setElasticDistanceScale(UUID holderUUID, Double scale, int maxKeepTicks, String reserved);
+ /**
+ * Sets elastic distance scale.
+ *
+ * @param knotPos the knot pos
+ * @param scale the scale
+ * @return the elastic distance scale
+ */
boolean setElasticDistanceScale(BlockPos knotPos, Double scale);
+
+ /**
+ * Sets elastic distance scale.
+ *
+ * @param knotPos the knot pos
+ * @param scale the scale
+ * @param maxKeepTicks the max keep ticks
+ * @return the elastic distance scale
+ */
boolean setElasticDistanceScale(BlockPos knotPos, Double scale, int maxKeepTicks);
+
+ /**
+ * Sets elastic distance scale.
+ *
+ * @param knotPos the knot pos
+ * @param scale the scale
+ * @param maxKeepTicks the max keep ticks
+ * @param reserved the reserved
+ * @return the elastic distance scale
+ */
boolean setElasticDistanceScale(BlockPos knotPos, Double scale, int maxKeepTicks, String reserved);
+ /**
+ * Apply leash forces.
+ */
/* ----------------------
* Apply physics
* ---------------------- */
void applyLeashForces();
+ /**
+ * Transfer leash boolean.
+ *
+ * @param holder the holder
+ * @param newHolder the new holder
+ * @return the boolean
+ */
/* ----------------------
* Transfer leash holders
* ---------------------- */
boolean transferLeash(Entity holder, Entity newHolder);
+
+ /**
+ * Transfer leash boolean.
+ *
+ * @param holder the holder
+ * @param newHolder the new holder
+ * @param reserved the reserved
+ * @return the boolean
+ */
boolean transferLeash(Entity holder, Entity newHolder, String reserved);
+ /**
+ * Transfer leash boolean.
+ *
+ * @param holderUUID the holder uuid
+ * @param newHolder the new holder
+ * @return the boolean
+ */
boolean transferLeash(UUID holderUUID, Entity newHolder);
+
+ /**
+ * Transfer leash boolean.
+ *
+ * @param holderUUID the holder uuid
+ * @param newHolder the new holder
+ * @param reserved the reserved
+ * @return the boolean
+ */
boolean transferLeash(UUID holderUUID, Entity newHolder, String reserved);
+ /**
+ * Transfer leash boolean.
+ *
+ * @param knotPos the knot pos
+ * @param newHolder the new holder
+ * @return the boolean
+ */
boolean transferLeash(BlockPos knotPos, Entity newHolder);
+
+ /**
+ * Transfer leash boolean.
+ *
+ * @param knotPos the knot pos
+ * @param newHolder the new holder
+ * @param reserved the reserved
+ * @return the boolean
+ */
boolean transferLeash(BlockPos knotPos, Entity newHolder, String reserved);
+ /**
+ * Has leash boolean.
+ *
+ * @return the boolean
+ */
/* ----------------------
* Query state
* ---------------------- */
boolean hasLeash();
+
+ /**
+ * Has knot leash boolean.
+ *
+ * @return the boolean
+ */
boolean hasKnotLeash();
+
+ /**
+ * Has holder leash boolean.
+ *
+ * @return the boolean
+ */
boolean hasHolderLeash();
+ /**
+ * Gets all leashes.
+ *
+ * @return the all leashes
+ */
Collection getAllLeashes();
+ /**
+ * Is leashed by boolean.
+ *
+ * @param holder the holder
+ * @return the boolean
+ */
boolean isLeashedBy(Entity holder);
+
+ /**
+ * Is leashed by boolean.
+ *
+ * @param holderUUID the holder uuid
+ * @return the boolean
+ */
boolean isLeashedBy(UUID holderUUID);
+
+ /**
+ * Is leashed by boolean.
+ *
+ * @param knotPos the knot pos
+ * @return the boolean
+ */
boolean isLeashedBy(BlockPos knotPos);
+ /**
+ * Is in delayed leash boolean.
+ *
+ * @param holderUUID the holder uuid
+ * @return the boolean
+ */
boolean isInDelayedLeash(UUID holderUUID);
+ /**
+ * Gets leash info.
+ *
+ * @param holder the holder
+ * @return the leash info
+ */
Optional getLeashInfo(Entity holder);
+
+ /**
+ * Gets leash info.
+ *
+ * @param holderUUID the holder uuid
+ * @return the leash info
+ */
Optional getLeashInfo(UUID holderUUID);
+
+ /**
+ * Gets leash info.
+ *
+ * @param knotPos the knot pos
+ * @return the leash info
+ */
Optional getLeashInfo(BlockPos knotPos);
+ /**
+ * Can be leashed boolean.
+ *
+ * @return the boolean
+ */
boolean canBeLeashed();
+
+ /**
+ * Can be attached to boolean.
+ *
+ * @param entity the entity
+ * @return the boolean
+ */
boolean canBeAttachedTo(Entity entity);
/* ----------------------
* Occupy / sync
* ---------------------- */
+
/**
* 抢占位(已离线玩家)。
* 用于解决玩家下线后所持有对象会移除持有者的问题(实际上是占用个弱集合)
+ *
+ * @return the optional
*/
Optional occupyLeash();
+ /**
+ * Mark for sync.
+ */
void markForSync();
+
+ /**
+ * Immediate sync.
+ */
void immediateSync();
+
+ /**
+ * Check sync.
+ */
void checkSync();
}
\ No newline at end of file
diff --git a/src/main/java/top/r3944realms/superleadrope/api/type/capabilty/ILeashState.java b/src/main/java/top/r3944realms/superleadrope/api/type/capabilty/ILeashState.java
index 8928ff6..81c559c 100644
--- a/src/main/java/top/r3944realms/superleadrope/api/type/capabilty/ILeashState.java
+++ b/src/main/java/top/r3944realms/superleadrope/api/type/capabilty/ILeashState.java
@@ -27,77 +27,283 @@ import org.jetbrains.annotations.Nullable;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
+
/**
* Capability interface for managing leash states of entities and knots.
*/
public interface ILeashState extends INBTSerializable {
+ /**
+ * Self entity.
+ *
+ * @return the entity
+ */
+ Entity self();
+ /**
+ * Has leash state boolean.
+ *
+ * @return the boolean
+ */
/* ----------------------
* Query leash states
* ---------------------- */
boolean hasLeashState();
+
+ /**
+ * Gets holder leash states.
+ *
+ * @return the holder leash states
+ */
Map getHolderLeashStates();
+
+ /**
+ * Gets knot leash states.
+ *
+ * @return the knot leash states
+ */
Map getKnotLeashStates();
+ /**
+ * Gets leash state.
+ *
+ * @param entity the entity
+ * @return the leash state
+ */
Optional getLeashState(Entity entity);
+
+ /**
+ * Gets leash state.
+ *
+ * @param uuid the uuid
+ * @return the leash state
+ */
Optional getLeashState(UUID uuid);
+
+ /**
+ * Gets leash state.
+ *
+ * @param pos the pos
+ * @return the leash state
+ */
Optional getLeashState(BlockPos pos);
+ /**
+ * Gets holder location offset.
+ *
+ * @param entity the entity
+ * @return the holder location offset
+ */
/* ----------------------
* Get offsets
* ---------------------- */
Optional getHolderLocationOffset(Entity entity);
+
+ /**
+ * Gets holder location offset.
+ *
+ * @param uuid the uuid
+ * @return the holder location offset
+ */
Optional getHolderLocationOffset(UUID uuid);
+
+ /**
+ * Gets holder location offset.
+ *
+ * @param pos the pos
+ * @return the holder location offset
+ */
Optional getHolderLocationOffset(BlockPos pos);
+
+ /**
+ * Gets leash apply entity location offset.
+ *
+ * @return the leash apply entity location offset
+ */
Optional getLeashApplyEntityLocationOffset();
+
+ /**
+ * Gets default leash apply entity location offset.
+ *
+ * @return the default leash apply entity location offset
+ */
Vec3 getDefaultLeashApplyEntityLocationOffset();
+ /**
+ * Reset all leash apply entity locations offset.
+ */
/* ----------------------
* Reset offsets (setApplyEntity null)
* ---------------------- */
void resetAllLeashApplyEntityLocationsOffset();
+
+ /**
+ * Reset all leash holder locations offset.
+ */
void resetAllLeashHolderLocationsOffset();
+
+ /**
+ * Reset leash holder location offset.
+ *
+ * @param holder the holder
+ */
void resetLeashHolderLocationOffset(Entity holder);
+
+ /**
+ * Reset leash holder location offset.
+ *
+ * @param holderUUID the holder uuid
+ */
void resetLeashHolderLocationOffset(UUID holderUUID);
+
+ /**
+ * Reset leash holder location offset.
+ *
+ * @param knotPos the knot pos
+ */
void resetLeashHolderLocationOffset(BlockPos knotPos);
+ /**
+ * Sets leash holder location offset.
+ *
+ * @param holder the holder
+ * @param offset the offset
+ */
/* ----------------------
* Set offsets (can setApplyEntity null)
* ---------------------- */
void setLeashHolderLocationOffset(Entity holder,@Nullable Vec3 offset);
+
+ /**
+ * Sets leash holder location offset.
+ *
+ * @param holderUUID the holder uuid
+ * @param offset the offset
+ */
void setLeashHolderLocationOffset(UUID holderUUID,@Nullable Vec3 offset);
+
+ /**
+ * Sets leash holder location offset.
+ *
+ * @param knotPos the knot pos
+ * @param offset the offset
+ */
void setLeashHolderLocationOffset(BlockPos knotPos,@Nullable Vec3 offset);
+
+ /**
+ * Sets leash apply entity location offset.
+ *
+ * @param offset the offset
+ */
void setLeashApplyEntityLocationOffset(Vec3 offset);
+ /**
+ * Add leash holder location offset.
+ *
+ * @param holder the holder
+ * @param offset the offset
+ */
/* ----------------------
* Add offsets
* ---------------------- */
void addLeashHolderLocationOffset(Entity holder, Vec3 offset);
+
+ /**
+ * Add leash holder location offset.
+ *
+ * @param holderUUID the holder uuid
+ * @param offset the offset
+ */
void addLeashHolderLocationOffset(UUID holderUUID, Vec3 offset);
+
+ /**
+ * Add leash holder location offset.
+ *
+ * @param knotPos the knot pos
+ * @param offset the offset
+ */
void addLeashHolderLocationOffset(BlockPos knotPos, Vec3 offset);
+
+ /**
+ * Add leash apply entity location offset.
+ *
+ * @param offset the offset
+ */
void addLeashApplyEntityLocationOffset(Vec3 offset);
+ /**
+ * Remove leash holder location offset.
+ *
+ * @param holder the holder
+ */
/* ----------------------
* Remove offsets (delete)
* ---------------------- */
void removeLeashHolderLocationOffset(Entity holder);
+
+ /**
+ * Remove leash holder location offset.
+ *
+ * @param holderUUID the holder uuid
+ */
void removeLeashHolderLocationOffset(UUID holderUUID);
+
+ /**
+ * Remove leash holder location offset.
+ *
+ * @param knotPos the knot pos
+ */
void removeLeashHolderLocationOffset(BlockPos knotPos);
+
+ /**
+ * Remove all leash holder location offset.
+ */
void removeAllLeashHolderLocationOffset();
+
+ /**
+ * Remove all leash holder uuid location offset.
+ */
void removeAllLeashHolderUUIDLocationOffset();
+
+ /**
+ * Remove all leash holder block pos location offset.
+ */
void removeAllLeashHolderBlockPosLocationOffset();
+
+ /**
+ * Remove leash apply entity location offset.
+ */
void removeLeashApplyEntityLocationOffset();
+ /**
+ * Copy.
+ *
+ * @param other the other
+ * @param newEntity the new entity
+ */
/* ----------------------
* Utility & sync
* ---------------------- */
void copy(ILeashState other, Entity newEntity);
+ /**
+ * Mark for sync.
+ */
void markForSync();
+
+ /**
+ * Immediate sync.
+ */
void immediateSync();
+
+ /**
+ * Check sync.
+ */
void checkSync();
+ /**
+ * The type Leash state.
+ */
/* ----------------------
* Data record
* ---------------------- */
@@ -106,21 +312,44 @@ public interface ILeashState extends INBTSerializable {
Vec3 applyEntityLocationOffset,
Vec3 defaultHolderLocationOffset
) {
+ /**
+ * Reset holder location offset leash state.
+ *
+ * @return the leash state
+ */
@Contract(" -> new")
public @NotNull LeashState resetHolderLocationOffset() {
return new LeashState(null, applyEntityLocationOffset, defaultHolderLocationOffset);
}
+ /**
+ * Sets holder location offset.
+ *
+ * @param holderLocationOffset the holder location offset
+ * @return the holder location offset
+ */
@Contract("_ -> new")
public @NotNull LeashState setHolderLocationOffset(@Nullable Vec3 holderLocationOffset) {
return new LeashState(holderLocationOffset, applyEntityLocationOffset, defaultHolderLocationOffset);
}
+ /**
+ * Sets apply entity location offset.
+ *
+ * @param applyEntityLocationOffset the apply entity location offset
+ * @return the apply entity location offset
+ */
@Contract("_ -> new")
public @NotNull LeashState setApplyEntityLocationOffset(@NotNull Vec3 applyEntityLocationOffset) {
return new LeashState(holderLocationOffset, applyEntityLocationOffset, defaultHolderLocationOffset);
}
+ /**
+ * Sets default holder location offset.
+ *
+ * @param defaultHolderLocationOffset the default holder location offset
+ * @return the default holder location offset
+ */
@Contract("_ -> new")
public @NotNull LeashState setDefaultHolderLocationOffset(@NotNull Vec3 defaultHolderLocationOffset) {
return new LeashState(holderLocationOffset, applyEntityLocationOffset, defaultHolderLocationOffset);
diff --git a/src/main/java/top/r3944realms/superleadrope/api/type/capabilty/LeashHolder.java b/src/main/java/top/r3944realms/superleadrope/api/type/capabilty/LeashHolder.java
index e97679a..7163778 100644
--- a/src/main/java/top/r3944realms/superleadrope/api/type/capabilty/LeashHolder.java
+++ b/src/main/java/top/r3944realms/superleadrope/api/type/capabilty/LeashHolder.java
@@ -20,10 +20,24 @@ import org.jetbrains.annotations.Nullable;
import java.util.UUID;
+/**
+ * The type Leash holder.
+ */
public record LeashHolder(@Nullable UUID holderUUID, @Nullable BlockPos knotPos, boolean isKnot) {
+ /**
+ * Instantiates a new Leash holder.
+ *
+ * @param holderUUID the holder uuid
+ */
public LeashHolder(UUID holderUUID) {
this (holderUUID, null, false);
}
+
+ /**
+ * Instantiates a new Leash holder.
+ *
+ * @param knotPos the knot pos
+ */
public LeashHolder(BlockPos knotPos) {
this(null, knotPos, true);
}
diff --git a/src/main/java/top/r3944realms/superleadrope/api/type/capabilty/LeashInfo.java b/src/main/java/top/r3944realms/superleadrope/api/type/capabilty/LeashInfo.java
index f92279a..fdd4755 100644
--- a/src/main/java/top/r3944realms/superleadrope/api/type/capabilty/LeashInfo.java
+++ b/src/main/java/top/r3944realms/superleadrope/api/type/capabilty/LeashInfo.java
@@ -24,6 +24,9 @@ import top.r3944realms.superleadrope.api.SuperLeadRopeApi;
import java.util.*;
+/**
+ * The type Leash info.
+ */
/* ----------------------
* Data record
* ---------------------- */
@@ -39,16 +42,40 @@ public record LeashInfo(
int keepLeashTicks, // 剩余 Tick 数
int maxKeepLeashTicks // 最大保持 Tick 数
) {
- // 预定义的标记常量
+ /**
+ * The constant MARK_NOT_UPDATE.
+ */
+// 预定义的标记常量
public static final String MARK_NOT_UPDATE = "NOT_UPDATE";
+ /**
+ * The constant MARK_ONLY_NOT_UPDATE_MAX_DISTANCE.
+ */
public static final String MARK_ONLY_NOT_UPDATE_MAX_DISTANCE = "NOT_UPDATE_MAX_DISTANCE";
+ /**
+ * The constant MARK_ONLY_NOT_UPDATE_ELASTIC_DISTANCE_SCALE.
+ */
public static final String MARK_ONLY_NOT_UPDATE_ELASTIC_DISTANCE_SCALE = "NOT_UPDATE_ELASTIC_DISTANCE_SCALE";
+ /**
+ * The constant EMPTY.
+ */
public static final LeashInfo EMPTY = new LeashInfo(
Optional.empty(), Optional.empty(), Optional.empty(),
Set.of(), "", 12.0D, 6.0D, 0, 0
);
+ /**
+ * Create leash info.
+ *
+ * @param entity the entity
+ * @param marks the marks
+ * @param reserved the reserved
+ * @param maxDistance the max distance
+ * @param elasticDistanceScale the elastic distance scale
+ * @param keepTicks the keep ticks
+ * @param maxKeepTicks the max keep ticks
+ * @return the leash info
+ */
/* ---------- Factory ---------- */
public static LeashInfo create(
Entity entity,
@@ -65,7 +92,18 @@ public record LeashInfo(
: new LeashInfo(entity.getUUID(), entity.getId(), marks, reserved, maxDistance, elasticDistanceScale, keepTicks, maxKeepTicks);
}
- // 向后兼容的工厂方法
+ /**
+ * Create leash info.
+ *
+ * @param entity the entity
+ * @param reserved the reserved
+ * @param maxDistance the max distance
+ * @param elasticDistanceScale the elastic distance scale
+ * @param keepTicks the keep ticks
+ * @param maxKeepTicks the max keep ticks
+ * @return the leash info
+ */
+// 向后兼容的工厂方法
public static LeashInfo create(
Entity entity,
String reserved,
@@ -77,30 +115,81 @@ public record LeashInfo(
return create(entity, Set.of(), reserved, maxDistance, elasticDistanceScale, keepTicks, maxKeepTicks);
}
+ /**
+ * Instantiates a new Leash info.
+ *
+ * @param holderUUID the holder uuid
+ * @param holderId the holder id
+ * @param reserved the reserved
+ * @param maxDistance the max distance
+ * @param elasticDistanceScale the elastic distance scale
+ * @param keepTicks the keep ticks
+ * @param maxKeepTicks the max keep ticks
+ */
public LeashInfo(UUID holderUUID, int holderId, String reserved,
Double maxDistance, Double elasticDistanceScale, int keepTicks, int maxKeepTicks) {
this(Optional.empty(), Optional.of(holderUUID), Optional.of(holderId),
Set.of(), reserved, maxDistance, elasticDistanceScale, keepTicks, maxKeepTicks);
}
+ /**
+ * Instantiates a new Leash info.
+ *
+ * @param holderUUID the holder uuid
+ * @param holderId the holder id
+ * @param marks the marks
+ * @param reserved the reserved
+ * @param maxDistance the max distance
+ * @param elasticDistanceScale the elastic distance scale
+ * @param keepTicks the keep ticks
+ * @param maxKeepTicks the max keep ticks
+ */
public LeashInfo(UUID holderUUID, int holderId, Set marks, String reserved,
Double maxDistance, Double elasticDistanceScale, int keepTicks, int maxKeepTicks) {
this(Optional.empty(), Optional.of(holderUUID), Optional.of(holderId),
marks, reserved, maxDistance, elasticDistanceScale, keepTicks, maxKeepTicks);
}
+ /**
+ * Instantiates a new Leash info.
+ *
+ * @param knotPos the knot pos
+ * @param holderId the holder id
+ * @param reserved the reserved
+ * @param maxDistance the max distance
+ * @param elasticDistanceScale the elastic distance scale
+ * @param keepTicks the keep ticks
+ * @param maxKeepTicks the max keep ticks
+ */
public LeashInfo(BlockPos knotPos, int holderId, String reserved,
Double maxDistance, Double elasticDistanceScale, int keepTicks, int maxKeepTicks) {
this(Optional.of(knotPos), Optional.empty(), Optional.of(holderId),
Set.of(), reserved, maxDistance, elasticDistanceScale, keepTicks, maxKeepTicks);
}
+ /**
+ * Instantiates a new Leash info.
+ *
+ * @param knotPos the knot pos
+ * @param holderId the holder id
+ * @param marks the marks
+ * @param reserved the reserved
+ * @param maxDistance the max distance
+ * @param elasticDistanceScale the elastic distance scale
+ * @param keepTicks the keep ticks
+ * @param maxKeepTicks the max keep ticks
+ */
public LeashInfo(BlockPos knotPos, int holderId, Set marks, String reserved,
Double maxDistance, Double elasticDistanceScale, int keepTicks, int maxKeepTicks) {
this(Optional.of(knotPos), Optional.empty(), Optional.of(holderId),
marks, reserved, maxDistance, elasticDistanceScale, keepTicks, maxKeepTicks);
}
+ /**
+ * Decrement keep ticks leash info.
+ *
+ * @return the leash info
+ */
/* ---------- State updates ---------- */
public LeashInfo decrementKeepTicks() {
return new LeashInfo(blockPosOpt, holderUUIDOpt, holderIdOpt, marks, reserved,
@@ -108,16 +197,34 @@ public record LeashInfo(
Math.max(0, keepLeashTicks - 1), maxKeepLeashTicks);
}
+ /**
+ * Reset keep ticks leash info.
+ *
+ * @return the leash info
+ */
public LeashInfo resetKeepTicks() {
return new LeashInfo(blockPosOpt, holderUUIDOpt, holderIdOpt, marks, reserved,
maxDistance, elasticDistanceScale,
maxKeepLeashTicks, maxKeepLeashTicks);
}
+ /**
+ * Transfer holder leash info.
+ *
+ * @param entity the entity
+ * @return the leash info
+ */
public LeashInfo transferHolder(Entity entity) {
return transferHolder(entity, reserved);
}
+ /**
+ * Transfer holder leash info.
+ *
+ * @param entity the entity
+ * @param newReserved the new reserved
+ * @return the leash info
+ */
public LeashInfo transferHolder(Entity entity, String newReserved) {
boolean isKnot = SuperLeadRopeApi.isSuperLeadKnot(entity);
return new LeashInfo(
@@ -131,6 +238,9 @@ public record LeashInfo(
/**
* 修改保留字段
+ *
+ * @param newReserved the new reserved
+ * @return the leash info
*/
public LeashInfo withReserved(String newReserved) {
return new LeashInfo(blockPosOpt, holderUUIDOpt, holderIdOpt, marks, newReserved,
@@ -139,6 +249,9 @@ public record LeashInfo(
/**
* 修改标记集合
+ *
+ * @param newMarks the new marks
+ * @return the leash info
*/
public LeashInfo withMarks(Set newMarks) {
return new LeashInfo(blockPosOpt, holderUUIDOpt, holderIdOpt, Set.copyOf(newMarks), reserved,
@@ -149,11 +262,18 @@ public record LeashInfo(
/**
* 添加无需更新标记(如果不存在则添加)
+ *
+ * @return the leash info
*/
public LeashInfo markNotUpdate() {
return hasMark(MARK_NOT_UPDATE) ? this : addMark(MARK_NOT_UPDATE);
}
+ /**
+ * Mark not update distance leash info.
+ *
+ * @return the leash info
+ */
public LeashInfo markNotUpdateDistance() {
if (hasMark(MARK_NOT_UPDATE)) {
return this;
@@ -167,6 +287,11 @@ public record LeashInfo(
return this.addMark(MARK_ONLY_NOT_UPDATE_MAX_DISTANCE);
}
+ /**
+ * Mark not update scale leash info.
+ *
+ * @return the leash info
+ */
public LeashInfo markNotUpdateScale() {
if (hasMark(MARK_NOT_UPDATE)) {
return this;
@@ -182,6 +307,8 @@ public record LeashInfo(
/**
* 移除无需更新标记
+ *
+ * @return the leash info
*/
public LeashInfo unmarkNotUpdate() {
return removeMarks(MARK_NOT_UPDATE, MARK_ONLY_NOT_UPDATE_MAX_DISTANCE, MARK_ONLY_NOT_UPDATE_ELASTIC_DISTANCE_SCALE);
@@ -189,6 +316,8 @@ public record LeashInfo(
/**
* 移除无需更新距离标记
+ *
+ * @return the leash info
*/
public LeashInfo unmarkNotUpdateDistance() {
return removeMarks(MARK_NOT_UPDATE, MARK_ONLY_NOT_UPDATE_MAX_DISTANCE);
@@ -196,6 +325,8 @@ public record LeashInfo(
/**
* 移除无需更新比例标记
+ *
+ * @return the leash info
*/
public LeashInfo unmarkNotUpdateScale() {
return removeMarks(MARK_NOT_UPDATE, MARK_ONLY_NOT_UPDATE_ELASTIC_DISTANCE_SCALE);
@@ -203,6 +334,8 @@ public record LeashInfo(
/**
* 检查是否包含无需更新标记
+ *
+ * @return the boolean
*/
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean isNotUpdate() {
@@ -211,6 +344,8 @@ public record LeashInfo(
/**
* 是否需距离更新标记
+ *
+ * @return the boolean
*/
public boolean isNeedUpdateDistance() {
return !isNotUpdate() && !hasMark(MARK_ONLY_NOT_UPDATE_MAX_DISTANCE);
@@ -218,6 +353,8 @@ public record LeashInfo(
/**
* 是否需比例更新
+ *
+ * @return the boolean
*/
public boolean isNeedUpdateScale() {
return !isNotUpdate() && !hasMark(MARK_ONLY_NOT_UPDATE_ELASTIC_DISTANCE_SCALE);
@@ -225,6 +362,9 @@ public record LeashInfo(
/**
* 添加标记(如果不存在则添加)
+ *
+ * @param mark the mark
+ * @return the leash info
*/
public LeashInfo addMark(String mark) {
if (marks.contains(mark)) {
@@ -238,6 +378,9 @@ public record LeashInfo(
/**
* 添加多个标记(自动检测并跳过重复标记)
+ *
+ * @param marksToAdd the marks to add
+ * @return the leash info
*/
public LeashInfo addMarks(String @NotNull ... marksToAdd) {
Set newMarks = new HashSet<>(marks);
@@ -253,6 +396,9 @@ public record LeashInfo(
/**
* 添加多个标记(集合版本)
+ *
+ * @param marksToAdd the marks to add
+ * @return the leash info
*/
public LeashInfo addMarks(@NotNull Collection marksToAdd) {
return addMarks(marksToAdd.toArray(new String[0]));
@@ -260,6 +406,9 @@ public record LeashInfo(
/**
* 移除单个标记
+ *
+ * @param mark the mark
+ * @return the leash info
*/
public LeashInfo removeMark(String mark) {
if (!marks.contains(mark)) {
@@ -273,6 +422,9 @@ public record LeashInfo(
/**
* 移除多个标记
+ *
+ * @param marksToRemove the marks to remove
+ * @return the leash info
*/
public LeashInfo removeMarks(String @NotNull ... marksToRemove) {
Set newMarks = new HashSet<>(marks);
@@ -288,6 +440,9 @@ public record LeashInfo(
/**
* 移除多个标记(集合版本)
+ *
+ * @param marksToRemove the marks to remove
+ * @return the leash info
*/
public LeashInfo removeMarks(@NotNull Collection marksToRemove) {
return removeMarks(marksToRemove.toArray(new String[0]));
@@ -295,6 +450,9 @@ public record LeashInfo(
/**
* 检查是否包含指定标记
+ *
+ * @param mark the mark
+ * @return the boolean
*/
public boolean hasMark(String mark) {
return marks.contains(mark);
@@ -302,6 +460,9 @@ public record LeashInfo(
/**
* 检查是否包含所有指定标记
+ *
+ * @param marksToCheck the marks to check
+ * @return the boolean
*/
@Contract(pure = true)
public boolean hasAllMarks(String @NotNull ... marksToCheck) {
@@ -315,6 +476,9 @@ public record LeashInfo(
/**
* 检查是否包含任意指定标记
+ *
+ * @param marksToCheck the marks to check
+ * @return the boolean
*/
@Contract(pure = true)
public boolean hasAnyMark(String @NotNull ... marksToCheck) {
@@ -328,6 +492,8 @@ public record LeashInfo(
/**
* 获取所有标记(不可修改的视图)
+ *
+ * @return the marks
*/
@Contract(pure = true)
public @Unmodifiable Set getMarks() {
@@ -336,6 +502,8 @@ public record LeashInfo(
/**
* 清除所有标记
+ *
+ * @return the leash info
*/
public LeashInfo clearAllMarks() {
if (marks.isEmpty()) {
diff --git a/src/main/java/top/r3944realms/superleadrope/api/type/util/ILeashHelper.java b/src/main/java/top/r3944realms/superleadrope/api/type/util/ILeashHelper.java
index d975c5f..c7d8272 100644
--- a/src/main/java/top/r3944realms/superleadrope/api/type/util/ILeashHelper.java
+++ b/src/main/java/top/r3944realms/superleadrope/api/type/util/ILeashHelper.java
@@ -17,6 +17,8 @@ package top.r3944realms.superleadrope.api.type.util;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
+import net.minecraft.world.phys.AABB;
+import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import top.r3944realms.superleadrope.api.SuperLeadRopeApi;
import top.r3944realms.superleadrope.api.type.capabilty.ILeashData;
@@ -25,62 +27,208 @@ import top.r3944realms.superleadrope.api.type.capabilty.LeashInfo;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
+import java.util.function.Predicate;
import java.util.function.Supplier;
+import java.util.stream.Collectors;
+/**
+ * 拴绳数据Helper
+ */
public interface ILeashHelper {
+ /**
+ * 持有者角度Helper
+ *
+ * @param holder 持有者
+ * @return IHolder holder helper
+ */
IHolder getHolderHelper(Entity holder);
+
+ /**
+ * Gets leashed helper.
+ *
+ * @param leashed the leashed
+ * @return the leashed helper
+ */
ILeashed getLeashedHelper(Entity leashed);
+
+ /**
+ * The interface Holder.
+ */
interface IHolder {
+ /**
+ * 获取持有者实体
+ *
+ * @return 持有者 holder entity
+ */
Entity getHolderEntity();
/**
- * 获取该实体持有的所有拴绳数据
+ * 获取该实体持有的所有实体的拴绳数据能力
+ *
+ * @return {@link Set 持有的实体的拴绳数据能力集合}
*/
- Set getAllLeashData();
+ Set getAllLeash();
+
+ /**
+ * 获取该实体持有的所有实体实例
+ *
+ * @return {@link Set 持有的实体集合}
+ */
+ default Set getAllLeashedEntities() {
+ return getAllLeash().stream().map(ILeashData::self).collect(Collectors.toSet());
+ }
+ /**
+ * 获取该实体持有的指定实体实例
+ *
+ * @param clazz 实体类型
+ * @param box 搜索范围
+ * @param filter {@link Predicate 实体过滤器}
+ *
+ * @return {@link Set 持有的实体集合}
+ */
+ default Set getLeashEntities (Class clazz, AABB box, Predicate filter) {
+ return getLeash(clazz, box, filter).stream().map(ILeashData::self).collect(Collectors.toSet());
+ }
+ /**
+ * 获取该实体持有的符合条件实体的拴绳数据能力
+ *
+ * @param clazz 实体类型
+ * @param box 搜索范围
+ * @param filter {@link Predicate 实体过滤器}
+ *
+ * @return {@link Set 持有的实体的拴绳数据能力集合}
+ */
+ Set getLeash(Class clazz, AABB box, Predicate filter);
+
+ /**
+ * 获取该实体持有的符合条件实体实例
+ *
+ * @param clazz 实体类型
+ * @param fetchDistance 搜索范围(以实体为中心的正方体{@link AABB#ofSize(Vec3, double, double, double) 包围盒})
+ * @param filter {@link Predicate 实体过滤器}
+ *
+ * @return {@link Set 持有的实体实例}
+ */
+ default Set getLeashEntities (Class clazz, double fetchDistance, Predicate filter) {
+ return getLeash(clazz, fetchDistance, filter).stream().map(ILeashData::self).collect(Collectors.toSet());
+ }
+
+ /**
+ * 获取该实体持有的符合条件实体的拴绳数据能力
+ *
+ * @param clazz 实体类型
+ * @param fetchDistance 搜索范围(以实体为中心的正方体{@link AABB#ofSize(Vec3, double, double, double) 包围盒})
+ * @param filter {@link Predicate 实体过滤器}
+ *
+ * @return {@link Set 持有的实体的拴绳数据能力集合}
+ */
+ default Set getLeash(Class clazz, double fetchDistance, Predicate filter) {
+ return getLeash(clazz, AABB.ofSize(getHolderEntity().position(), fetchDistance, fetchDistance, fetchDistance), filter);
+ }
+ /**
+ * 获取该实体持有的符合条件实体实例
+ *
+ * @param clazz 实体类型
+ * @param filter {@link Predicate 实体过滤器}
+ *
+ * @return {@link Set 持有的实体实例}
+ */
+ default Set getLeashEntities (Class clazz, Predicate filter) {
+ return getLeash(clazz, filter).stream().map(ILeashData::self).collect(Collectors.toSet());
+ }
+
+ /**
+ * 获取该实体持有的符合条件实体的拴绳数据能力
+ *
+ * @param clazz 实体类型
+ * @param filter {@link Predicate 实体过滤器}
+ *
+ * @return {@link Set 持有的实体的拴绳数据能力集合}
+ */
+ default Set getLeash(Class clazz, Predicate filter) {
+ return getLeash(clazz, 1024D, filter);
+ }
+ /**
+ * 获取该实体持有的符合条件实体实例
+ *
+ * @param clazz 实体类型
+ *
+ * @return {@link Set 持有的实体实例}
+ */
+ default Set getLeashEntities (Class clazz) {
+ return getLeash(clazz).stream().map(ILeashData::self).collect(Collectors.toSet());
+ }
+
+ /**
+ * 获取该实体持有的符合条件实体的拴绳数据能力
+ *
+ * @param clazz 实体类型
+ *
+ * @return {@link Set 持有的实体的拴绳数据能力集合}
+ */
+ default Set getLeash(Class clazz) {
+ return getLeash(clazz, 1024D, null);
+ }
+
/**
* 获取该实体持有的拴绳数量
+ *
+ * @return the leash count
*/
default int getLeashCount() {
- return getAllLeashData().size();
+ return getAllLeash().size();
}
/**
* 检查是否持有任何拴绳
*/
default boolean hasLeashes() {
- return !getAllLeashData().isEmpty();
+ return !getAllLeash().isEmpty();
}
/**
* 释放所有持有的拴绳
*/
default void releaseAllLeashes() {
- getAllLeashData().forEach(i -> i.removeLeash(getHolderEntity()));
+ getAllLeash().forEach(i -> i.removeLeash(getHolderEntity()));
}
/**
* 检查是否持有特定实体的拴绳
+ *
+ * @param entity the entity
+ * @return the boolean
*/
default boolean isHoldingLeash(Entity entity) {
- return getAllLeashData().stream().anyMatch(i -> i.isLeashedBy(entity));
+ return getAllLeash().stream().anyMatch(i -> i.isLeashedBy(entity));
}
/**
* 检查是否持有特定实体的拴绳
+ *
+ * @param uuid the uuid
+ * @return the boolean
*/
default boolean isHoldingLeash(UUID uuid) {
- return getAllLeashData().stream().anyMatch(i -> i.isLeashedBy(uuid));
+ return getAllLeash().stream().anyMatch(i -> i.isLeashedBy(uuid));
}
/**
* 检查是否持有特定实体的拴绳
+ *
+ * @param blockPos the block pos
+ * @return the boolean
*/
default boolean isHoldingLeash(BlockPos blockPos) {
- return getAllLeashData().stream().anyMatch(i -> i.isLeashedBy(blockPos));
+ return getAllLeash().stream().anyMatch(i -> i.isLeashedBy(blockPos));
}
+
/**
* 拴住另一个实体
+ *
+ * @param target the target
+ * @return the boolean
*/
default boolean leashEntity(Entity target) {
if (SuperLeadRopeApi.isLeashable(target)) {
@@ -90,9 +238,20 @@ public interface ILeashHelper {
}
return false;
}
+
+ /**
+ * Leash entity boolean.
+ *
+ * @param uuid the uuid
+ * @return the boolean
+ */
boolean leashEntity(UUID uuid);
+
/**
* 解拴另一个实体
+ *
+ * @param target the target
+ * @return the boolean
*/
default boolean unleashEntity(Entity target) {
if (SuperLeadRopeApi.isLeashable(target)) {
@@ -102,65 +261,125 @@ public interface ILeashHelper {
}
return false;
}
+
+ /**
+ * Unleash entity boolean.
+ *
+ * @param uuid the uuid
+ * @return the boolean
+ */
boolean unleashEntity(UUID uuid);
}
+ /**
+ * The interface Leashed.
+ */
interface ILeashed {
/**
* 获取该实体的拴绳数据
+ *
+ * @return the leash data
*/
ILeashData getLeashData();
/**
* 绑定拴绳到实体
+ *
+ * @param holder the holder
+ * @return the boolean
*/
default boolean attachLeash(Entity holder) {
return getLeashData().addLeash(holder);
}
+
/**
* 绑定拴绳到实体
+ *
+ * @param holder the holder
+ * @param reserved the reserved
+ * @return the boolean
*/
default boolean attachLeash(Entity holder, String reserved) {
return getLeashData().addLeash(holder, reserved);
}
+
/**
* 绑定拴绳并设置参数
+ *
+ * @param holder the holder
+ * @param maxDistance the max distance
+ * @param elasticDistanceScale the elastic distance scale
+ * @return the boolean
*/
default boolean attachLeash(Entity holder, Double maxDistance, Double elasticDistanceScale) {
return getLeashData().addLeash(holder, maxDistance, elasticDistanceScale);
}
+
/**
* 绑定拴绳并设置参数
+ *
+ * @param holder the holder
+ * @param maxDistance the max distance
+ * @param elasticDistanceScale the elastic distance scale
+ * @param reserved the reserved
+ * @return the boolean
*/
default boolean attachLeash(Entity holder, Double maxDistance, Double elasticDistanceScale, String reserved) {
return getLeashData().addLeash(holder, maxDistance, elasticDistanceScale, reserved);
}
+
/**
* 绑定拴绳并设置参数
+ *
+ * @param holder the holder
+ * @param maxDistance the max distance
+ * @param elasticDistanceScale the elastic distance scale
+ * @param maxKeepTicks the max keep ticks
+ * @return the boolean
*/
default boolean attachLeash(Entity holder, Double maxDistance, Double elasticDistanceScale, int maxKeepTicks) {
return getLeashData().addLeash(holder, maxDistance, elasticDistanceScale, maxKeepTicks);
}
+
/**
* 绑定拴绳并设置参数
+ *
+ * @param holder the holder
+ * @param maxDistance the max distance
+ * @param elasticDistanceScale the elastic distance scale
+ * @param maxKeepTicks the max keep ticks
+ * @param reserved the reserved
+ * @return the boolean
*/
default boolean attachLeash(Entity holder, Double maxDistance, Double elasticDistanceScale, int maxKeepTicks, String reserved) {
return getLeashData().addLeash(holder, maxDistance, elasticDistanceScale, maxKeepTicks, reserved);
}
+
/**
* 解绑拴绳(自动判断类型)
+ *
+ * @param entity the entity
+ * @return the boolean
*/
default boolean detachLeash(Entity entity) {
return getLeashData().removeLeash(entity);
}
+
/**
* 解绑拴绳
+ *
+ * @param uuid the uuid
+ * @return the boolean
*/
default boolean detachLeash(UUID uuid) {
return getLeashData().removeLeash(uuid);
}
+
/**
* 解绑拴绳
+ *
+ * @param blockPos the block pos
+ * @return the boolean
*/
default boolean detachLeash(BlockPos blockPos) {
return getLeashData().removeLeash(blockPos);
@@ -172,38 +391,53 @@ public interface ILeashHelper {
default void detachAllLeashes() {
getLeashData().removeAllLeashes();
}
+
/**
* 解绑所有实体拴绳
*/
default void removeAllHolderLeashes() {
getLeashData().removeAllHolderLeashes();
}
+
/**
* 解绑所有绳结拴绳
*/
default void removeAllKnotLeashes() {
getLeashData().removeAllKnotLeashes();
}
+
/**
* 检查是否被拴住
+ *
+ * @return the boolean
*/
default boolean isLeashed() {
return getLeashData().hasLeash();
}
+
/**
* 检查是否被持有者拴住
+ *
+ * @return the boolean
*/
default boolean hasHolderLeashed() {
return getLeashData().hasHolderLeash();
}
+
/**
* 检查是否被绳结拴住
+ *
+ * @return the boolean
*/
default boolean isKnotLeashed() {
return getLeashData().hasKnotLeash();
}
+
/**
* 检查是否被特定实体拴住(自动判断类型)
+ *
+ * @param entity the entity
+ * @return the boolean
*/
default boolean isLeashedBy(Entity entity) {
return getLeashData().isLeashedBy(entity);
@@ -211,6 +445,9 @@ public interface ILeashHelper {
/**
* 检查是否被特定UUID实体拴住
+ *
+ * @param uuid the uuid
+ * @return the boolean
*/
default boolean isLeashedBy(UUID uuid) {
return getLeashData().isLeashedBy(uuid);
@@ -218,6 +455,9 @@ public interface ILeashHelper {
/**
* 检查是否被特定绳结实体拴住
+ *
+ * @param blockPos the block pos
+ * @return the boolean
*/
default boolean isLeashedBy(BlockPos blockPos) {
return getLeashData().isLeashedBy(blockPos);
@@ -225,58 +465,109 @@ public interface ILeashHelper {
/**
* 获取拴绳信息(自动判断类型)
+ *
+ * @param entity the entity
+ * @return the leash info
*/
default Optional getLeashInfo(Entity entity) {
return getLeashData().getLeashInfo(entity);
}
+
/**
* 获取拴绳信息
+ *
+ * @param holderUUID the holder uuid
+ * @return the leash info
*/
default Optional getLeashInfo(UUID holderUUID) {
return getLeashData().getLeashInfo(holderUUID);
}
+
/**
* 获取拴绳信息
+ *
+ * @param knotPos the knot pos
+ * @return the leash info
*/
default Optional getLeashInfo(BlockPos knotPos) {
return getLeashData().getLeashInfo(knotPos);
}
+
/**
* 转移拴绳到新持有者(自动判断类型)
+ *
+ * @param fromEntity the from entity
+ * @param toEntity the to entity
+ * @return the boolean
*/
default boolean transferLeash(Entity fromEntity, Entity toEntity) {
return getLeashData().transferLeash(fromEntity, toEntity);
}
+
/**
* 转移拴绳到新持有者(自动判断类型)
+ *
+ * @param fromEntity the from entity
+ * @param toEntity the to entity
+ * @param reserved the reserved
+ * @return the boolean
*/
default boolean transferLeash(Entity fromEntity, Entity toEntity, String reserved) {
return getLeashData().transferLeash(fromEntity, toEntity, reserved);
}
+
/**
* 转移拴绳到新持有者
+ *
+ * @param fromEntityUUID the from entity uuid
+ * @param toEntity the to entity
+ * @return the boolean
*/
default boolean transferLeash(UUID fromEntityUUID, Entity toEntity) {
return getLeashData().transferLeash(fromEntityUUID, toEntity);
}
+
/**
* 转移拴绳到新持有者
+ *
+ * @param fromEntityUUID the from entity uuid
+ * @param toEntity the to entity
+ * @param reserved the reserved
+ * @return the boolean
*/
default boolean transferLeash(UUID fromEntityUUID, Entity toEntity, String reserved) {
return getLeashData().transferLeash(fromEntityUUID, toEntity, reserved);
}
+
/**
* 转移拴绳到新持有者
+ *
+ * @param fromKnotBlockPos the from knot block pos
+ * @param toEntity the to entity
+ * @return the boolean
*/
default boolean transferLeash(BlockPos fromKnotBlockPos, Entity toEntity) {
return getLeashData().transferLeash(fromKnotBlockPos, toEntity);
}
+
/**
* 转移拴绳到新持有者
+ *
+ * @param fromKnotBlockPos the from knot block pos
+ * @param toEntity the to entity
+ * @param reserved the reserved
+ * @return the boolean
*/
default boolean transferLeash(BlockPos fromKnotBlockPos, Entity toEntity, String reserved) {
return getLeashData().transferLeash(fromKnotBlockPos, toEntity, reserved);
}
+
+ /**
+ * Is in delayed leash boolean.
+ *
+ * @param holderUUID the holder uuid
+ * @return the boolean
+ */
default boolean isInDelayedLeash(UUID holderUUID) {
return getLeashData().isInDelayedLeash(holderUUID);
}
@@ -291,6 +582,8 @@ public interface ILeashHelper {
/**
* 检查是否可以被拴绳
+ *
+ * @return the boolean
*/
default boolean canBeLeashed() {
return getLeashData().canBeLeashed();
@@ -298,17 +591,37 @@ public interface ILeashHelper {
/**
* 检查是否可以拴到特定目标
+ *
+ * @param holder the holder
+ * @return the boolean
*/
default boolean canBeAttachedTo(Entity holder) {
return getLeashData().canBeAttachedTo(holder);
}
}
+
+ /**
+ * Choose method with boolean ret boolean.
+ *
+ * @param cond the cond
+ * @param trueSupplier the true supplier
+ * @param falseSupplier the false supplier
+ * @return the boolean
+ */
static boolean chooseMethodWithBooleanRet(@NotNull Supplier cond, Supplier trueSupplier, Supplier falseSupplier) {
if (cond.get()) {
return trueSupplier.get();
}
return falseSupplier.get();
}
+
+ /**
+ * Choose method with void ret.
+ *
+ * @param cond the cond
+ * @param trueSupplier the true supplier
+ * @param falseSupplier the false supplier
+ */
static void chooseMethodWithVoidRet(@NotNull Supplier cond, Supplier trueSupplier, Supplier falseSupplier) {
if (cond.get()) {
trueSupplier.get();
diff --git a/src/main/java/top/r3944realms/superleadrope/api/workspace/IWorkSpaceHelper.java b/src/main/java/top/r3944realms/superleadrope/api/workspace/IWorkSpaceHelper.java
index 7d33f8c..708133b 100644
--- a/src/main/java/top/r3944realms/superleadrope/api/workspace/IWorkSpaceHelper.java
+++ b/src/main/java/top/r3944realms/superleadrope/api/workspace/IWorkSpaceHelper.java
@@ -18,6 +18,7 @@ package top.r3944realms.superleadrope.api.workspace;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
+import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import top.r3944realms.superleadrope.api.type.capabilty.ILeashData;
@@ -28,12 +29,78 @@ import java.util.List;
import java.util.Optional;
import java.util.function.Predicate;
+/**
+ * The interface Work space helper.
+ */
public interface IWorkSpaceHelper {
+ /**
+ * Leashable in area list.
+ *
+ * @param pLevel the p level
+ * @param pPos the p pos
+ * @param filter the filter
+ * @param fetchDistance the fetch distance
+ * @return the list
+ */
@NotNull List leashableInArea(@NotNull Level pLevel, Vec3 pPos, Predicate filter, double fetchDistance);
+
+ /**
+ * Leashable in area list.
+ *
+ * @param pLevel the p level
+ * @param clazz the clazz
+ * @param filter the filter
+ * @param box the box
+ * @return the list
+ */
+ @NotNull List leashableInArea(@NotNull Level pLevel, Class clazz,Predicate filter, AABB box);
+
+
+ /**
+ * Gets leash helper.
+ *
+ * @return the leash helper
+ */
ILeashHelper getLeashHelper();
+
+ /**
+ * Is super lead knot boolean.
+ *
+ * @param pEntity the p entity
+ * @return the boolean
+ */
boolean isSuperLeadKnot(Entity pEntity);
+
+ /**
+ * Gets super lead pos.
+ *
+ * @param pEntity the p entity
+ * @return the super lead pos
+ * @throws IllegalArgumentException the illegal argument exception
+ */
BlockPos getSuperLeadPos(Entity pEntity) throws IllegalArgumentException;
+
+ /**
+ * Is leashable boolean.
+ *
+ * @param pEntity the p entity
+ * @return the boolean
+ */
boolean isLeashable(@NotNull Entity pEntity);
+
+ /**
+ * Gets leash data.
+ *
+ * @param pEntity the p entity
+ * @return the leash data
+ */
Optional getLeashData(@NotNull Entity pEntity);
+
+ /**
+ * Gets leash state.
+ *
+ * @param pEntity the p entity
+ * @return the leash state
+ */
Optional getLeashState(@NotNull Entity pEntity);
}
diff --git a/src/main/java/top/r3944realms/superleadrope/api/workspace/Services.java b/src/main/java/top/r3944realms/superleadrope/api/workspace/Services.java
index 7e92924..4f8048b 100644
--- a/src/main/java/top/r3944realms/superleadrope/api/workspace/Services.java
+++ b/src/main/java/top/r3944realms/superleadrope/api/workspace/Services.java
@@ -19,8 +19,22 @@ import top.r3944realms.superleadrope.api.SuperLeadRopeApi;
import java.util.ServiceLoader;
+/**
+ * The type Services.
+ */
public class Services {
+ /**
+ * The constant WORK_SPACE.
+ */
public static final IWorkSpaceHelper WORK_SPACE = load(IWorkSpaceHelper.class);
+
+ /**
+ * Load t.
+ *
+ * @param the type parameter
+ * @param clazz the clazz
+ * @return the t
+ */
public static T load(Class clazz) {
final T loadedService = ServiceLoader.load(clazz)
.findFirst()
diff --git a/src/main/java/top/r3944realms/superleadrope/client/ClientEventHandler.java b/src/main/java/top/r3944realms/superleadrope/client/ClientEventHandler.java
index 4af923b..349a917 100644
--- a/src/main/java/top/r3944realms/superleadrope/client/ClientEventHandler.java
+++ b/src/main/java/top/r3944realms/superleadrope/client/ClientEventHandler.java
@@ -41,10 +41,21 @@ import java.io.IOException;
import static top.r3944realms.superleadrope.core.util.PotatoModeHelper.getCurrentMode;
+/**
+ * The type Client event handler.
+ */
@OnlyIn(Dist.CLIENT)
public class ClientEventHandler {
+ /**
+ * The type Game.
+ */
@net.minecraftforge.fml.common.Mod.EventBusSubscriber(modid = SuperLeadRope.MOD_ID, value = Dist.CLIENT, bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.FORGE)
public static class Game {
+ /**
+ * On level renderer.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onLevelRenderer (RenderLevelStageEvent event) {
if (event.getStage() != RenderLevelStageEvent.Stage.AFTER_ENTITIES) {
@@ -52,15 +63,30 @@ public class ClientEventHandler {
}
LeashRenderHandler.onRenderLevelStage(event.getPoseStack(), event.getPartialTick());
}
- // 未使用-注释
+
+ /**
+ * On player logged out.
+ *
+ * @param event the event
+ */
+// 未使用-注释
@SubscribeEvent
public static void onPlayerLoggedOut(ClientPlayerNetworkEvent.LoggingOut event) {
// 清理客户端缓存数据
EternalPotatoFacade.clear();
}
}
+
+ /**
+ * The type Mod.
+ */
@net.minecraftforge.fml.common.Mod.EventBusSubscriber(modid = SuperLeadRope.MOD_ID, value = Dist.CLIENT, bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD)
public static class Mod {
+ /**
+ * On client initializer.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onClientInitializer (FMLClientSetupEvent event) {
event.enqueueWork(() -> {
@@ -76,14 +102,33 @@ public class ClientEventHandler {
EternalPotatoFacade.init(mode, false); // 客户端
});
}
+
+ /**
+ * On register model layer.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onRegisterModelLayer (EntityRenderersEvent.RegisterLayerDefinitions event) {
event.registerLayerDefinition(SLPModelLayers.SUPER_LEASH_KNOT, SuperLeashKnotModel::createBodyLayer);
}
+
+ /**
+ * On register renderer.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void onRegisterRenderer (EntityRenderersEvent.RegisterRenderers event) {
event.registerEntityRenderer(SLPEntityTypes.SUPER_LEAD_KNOT.get(), SuperLeashKnotRenderer::new);
}
+
+ /**
+ * On register shaders.
+ *
+ * @param event the event
+ * @throws IOException the io exception
+ */
@SubscribeEvent
public static void onRegisterShaders(RegisterShadersEvent event) throws IOException {
SLPShaderRegistry.registerShaders(event);
diff --git a/src/main/java/top/r3944realms/superleadrope/client/model/SuperLeashKnotModel.java b/src/main/java/top/r3944realms/superleadrope/client/model/SuperLeashKnotModel.java
index 7917a11..f36b00f 100644
--- a/src/main/java/top/r3944realms/superleadrope/client/model/SuperLeashKnotModel.java
+++ b/src/main/java/top/r3944realms/superleadrope/client/model/SuperLeashKnotModel.java
@@ -28,18 +28,33 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.NotNull;
+/**
+ * The type Super leash knot model.
+ *
+ * @param the type parameter
+ */
@OnlyIn(Dist.CLIENT)
public class SuperLeashKnotModel extends HierarchicalModel {
private static final String KNOT = "knot";
private final ModelPart root;
private final ModelPart knot;
- public SuperLeashKnotModel(ModelPart root) {
+ /**
+ * Instantiates a new Super leash knot model.
+ *
+ * @param root the root
+ */
+ public SuperLeashKnotModel(ModelPart root) {
this.root = root;
this.knot = root.getChild(KNOT);
}
- public static LayerDefinition createBodyLayer() {
+ /**
+ * Create body layer layer definition.
+ *
+ * @return the layer definition
+ */
+ public static LayerDefinition createBodyLayer() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();
partdefinition.addOrReplaceChild(KNOT,
diff --git a/src/main/java/top/r3944realms/superleadrope/client/model/geom/SLPModelLayers.java b/src/main/java/top/r3944realms/superleadrope/client/model/geom/SLPModelLayers.java
index 3c937d4..85a2b64 100644
--- a/src/main/java/top/r3944realms/superleadrope/client/model/geom/SLPModelLayers.java
+++ b/src/main/java/top/r3944realms/superleadrope/client/model/geom/SLPModelLayers.java
@@ -21,8 +21,14 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import top.r3944realms.superleadrope.SuperLeadRope;
+/**
+ * The type Slp model layers.
+ */
@OnlyIn(Dist.CLIENT)
public class SLPModelLayers {
+ /**
+ * The constant SUPER_LEASH_KNOT.
+ */
public static final ModelLayerLocation SUPER_LEASH_KNOT =
new ModelLayerLocation(
new ResourceLocation(SuperLeadRope.MOD_ID, "super_leash_knot"),
diff --git a/src/main/java/top/r3944realms/superleadrope/client/renderer/LeashRenderHandler.java b/src/main/java/top/r3944realms/superleadrope/client/renderer/LeashRenderHandler.java
index 45c8bfb..ec7053d 100644
--- a/src/main/java/top/r3944realms/superleadrope/client/renderer/LeashRenderHandler.java
+++ b/src/main/java/top/r3944realms/superleadrope/client/renderer/LeashRenderHandler.java
@@ -31,7 +31,16 @@ import top.r3944realms.superleadrope.util.capability.LeashDataInnerAPI;
import java.util.Optional;
import java.util.UUID;
+/**
+ * The type Leash render handler.
+ */
public class LeashRenderHandler {
+ /**
+ * On render level stage.
+ *
+ * @param poseStack the pose stack
+ * @param partialTick the partial tick
+ */
public static void onRenderLevelStage(PoseStack poseStack, float partialTick) {
renderAllCustomLeashes(poseStack, partialTick);
}
diff --git a/src/main/java/top/r3944realms/superleadrope/client/renderer/SLPRenderType.java b/src/main/java/top/r3944realms/superleadrope/client/renderer/SLPRenderType.java
index dc6756b..8b481d7 100644
--- a/src/main/java/top/r3944realms/superleadrope/client/renderer/SLPRenderType.java
+++ b/src/main/java/top/r3944realms/superleadrope/client/renderer/SLPRenderType.java
@@ -23,12 +23,40 @@ import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
import top.r3944realms.superleadrope.SuperLeadRope;
+/**
+ * The type Slp render type.
+ */
public class SLPRenderType extends RenderType {
+ /**
+ * Instantiates a new Slp render type.
+ *
+ * @param name the name
+ * @param format the format
+ * @param mode the mode
+ * @param bufferSize the buffer size
+ * @param affectsCrumbling the affects crumbling
+ * @param sortOnUpload the sort on upload
+ * @param setupState the setup state
+ * @param clearState the clear state
+ */
public SLPRenderType(String name, VertexFormat format, VertexFormat.Mode mode, int bufferSize, boolean affectsCrumbling, boolean sortOnUpload, Runnable setupState, Runnable clearState) {
super(name, format, mode, bufferSize, affectsCrumbling, sortOnUpload, setupState, clearState);
}
+
+ /**
+ * The Super leash.
+ */
static RenderType SUPER_LEASH;
+ /**
+ * The constant POSITION_COLOR_LIGHTMAP_NORMAL.
+ */
public static final VertexFormat POSITION_COLOR_LIGHTMAP_NORMAL;
+
+ /**
+ * Leash type render type.
+ *
+ * @return the render type
+ */
public static RenderType leashType() {
return SUPER_LEASH;
}
diff --git a/src/main/java/top/r3944realms/superleadrope/client/renderer/SLPShaderRegistry.java b/src/main/java/top/r3944realms/superleadrope/client/renderer/SLPShaderRegistry.java
index a897072..ccaeb76 100644
--- a/src/main/java/top/r3944realms/superleadrope/client/renderer/SLPShaderRegistry.java
+++ b/src/main/java/top/r3944realms/superleadrope/client/renderer/SLPShaderRegistry.java
@@ -23,9 +23,22 @@ import top.r3944realms.superleadrope.SuperLeadRope;
import java.io.IOException;
+/**
+ * The type Slp shader registry.
+ */
public class SLPShaderRegistry {
private static final ResourceLocation RL_SUPER_ROPE = new ResourceLocation(SuperLeadRope.MOD_ID, "super_leash");
+ /**
+ * The constant ROPE_SHADER.
+ */
public static ShaderInstance ROPE_SHADER;
+
+ /**
+ * Register shaders.
+ *
+ * @param event the event
+ * @throws IOException the io exception
+ */
public static void registerShaders(RegisterShadersEvent event) throws IOException {
event.registerShader(
new ShaderInstance(
diff --git a/src/main/java/top/r3944realms/superleadrope/client/renderer/SuperLeashRenderer.java b/src/main/java/top/r3944realms/superleadrope/client/renderer/SuperLeashRenderer.java
index 80543ca..c02eda5 100644
--- a/src/main/java/top/r3944realms/superleadrope/client/renderer/SuperLeashRenderer.java
+++ b/src/main/java/top/r3944realms/superleadrope/client/renderer/SuperLeashRenderer.java
@@ -28,11 +28,21 @@ import net.minecraft.world.phys.Vec3;
import org.joml.Matrix4f;
import top.r3944realms.superleadrope.client.renderer.state.SuperLeashRenderState;
+/**
+ * The type Super leash renderer.
+ */
@SuppressWarnings("UnnecessaryLocalVariable")
public class SuperLeashRenderer {
private static final int LEASH_STEPS = 24;
+ /**
+ * Render leash.
+ *
+ * @param state the state
+ * @param poseStack the pose stack
+ * @param buffer the buffer
+ */
public static void renderLeash(SuperLeashRenderState state, PoseStack poseStack, MultiBufferSource buffer) {
poseStack.pushPose();
@@ -162,11 +172,51 @@ public class SuperLeashRenderer {
/** 横纵偏移数据 */
private static class Offsets {
- public final float dx, dy, dz; // 绳子差向量
- public final float xOffset, zOffset; // 横向偏移
- public final float yOffsetPass1, dyOffsetPass1; // pass1 纵向偏移
- public final float yOffsetPass2, dyOffsetPass2; // pass2 纵向偏移
+ /**
+ * The Dx.
+ */
+ public final float dx, /**
+ * The Dy.
+ */
+ dy, /**
+ * The Dz.
+ */
+ dz; // 绳子差向量
+ /**
+ * The X offset.
+ */
+ public final float xOffset, /**
+ * The Z offset.
+ */
+ zOffset; // 横向偏移
+ /**
+ * The Y offset pass 1.
+ */
+ public final float yOffsetPass1, /**
+ * The Dy offset pass 1.
+ */
+ dyOffsetPass1; // pass1 纵向偏移
+ /**
+ * The Y offset pass 2.
+ */
+ public final float yOffsetPass2, /**
+ * The Dy offset pass 2.
+ */
+ dyOffsetPass2; // pass2 纵向偏移
+ /**
+ * Instantiates a new Offsets.
+ *
+ * @param dx the dx
+ * @param dy the dy
+ * @param dz the dz
+ * @param xOffset the x offset
+ * @param zOffset the z offset
+ * @param yOffsetPass1 the y offset pass 1
+ * @param dyOffsetPass1 the dy offset pass 1
+ * @param yOffsetPass2 the y offset pass 2
+ * @param dyOffsetPass2 the dy offset pass 2
+ */
public Offsets(float dx, float dy, float dz,
float xOffset, float zOffset,
float yOffsetPass1, float dyOffsetPass1,
diff --git a/src/main/java/top/r3944realms/superleadrope/client/renderer/entity/SuperLeashKnotRenderer.java b/src/main/java/top/r3944realms/superleadrope/client/renderer/entity/SuperLeashKnotRenderer.java
index d1748f1..4cf30ce 100644
--- a/src/main/java/top/r3944realms/superleadrope/client/renderer/entity/SuperLeashKnotRenderer.java
+++ b/src/main/java/top/r3944realms/superleadrope/client/renderer/entity/SuperLeashKnotRenderer.java
@@ -31,10 +31,19 @@ import top.r3944realms.superleadrope.client.model.SuperLeashKnotModel;
import top.r3944realms.superleadrope.client.model.geom.SLPModelLayers;
import top.r3944realms.superleadrope.content.entity.SuperLeashKnotEntity;
+/**
+ * The type Super leash knot renderer.
+ */
@OnlyIn(Dist.CLIENT)
public class SuperLeashKnotRenderer extends EntityRenderer {
private static final ResourceLocation KNOT_LOCATION = new ResourceLocation(SuperLeadRope.MOD_ID, "textures/entity/super_lead_knot.png");
private final SuperLeashKnotModel model;
+
+ /**
+ * Instantiates a new Super leash knot renderer.
+ *
+ * @param context the context
+ */
public SuperLeashKnotRenderer(EntityRendererProvider.Context context) {
super(context);
this.model = new SuperLeashKnotModel<>(context.bakeLayer(SLPModelLayers.SUPER_LEASH_KNOT));
diff --git a/src/main/java/top/r3944realms/superleadrope/client/renderer/resolver/SuperLeashStateResolver.java b/src/main/java/top/r3944realms/superleadrope/client/renderer/resolver/SuperLeashStateResolver.java
index 7c6256c..cc4c564 100644
--- a/src/main/java/top/r3944realms/superleadrope/client/renderer/resolver/SuperLeashStateResolver.java
+++ b/src/main/java/top/r3944realms/superleadrope/client/renderer/resolver/SuperLeashStateResolver.java
@@ -36,6 +36,9 @@ import java.util.Map;
import java.util.Optional;
import java.util.UUID;
+/**
+ * The type Super leash state resolver.
+ */
//TODO: 未来实现更高级的渲染
public class SuperLeashStateResolver {
@@ -52,6 +55,15 @@ public class SuperLeashStateResolver {
/* ------------------------ 主解析方法 ------------------------ */
+ /**
+ * Resolve optional.
+ *
+ * @param holder the holder
+ * @param leashedEntity the leashed entity
+ * @param leashInfo the leash info
+ * @param partialTicks the partial ticks
+ * @return the optional
+ */
public static Optional resolve(Entity holder, Entity leashedEntity,
LeashInfo leashInfo, float partialTicks) {
@@ -156,12 +168,14 @@ public class SuperLeashStateResolver {
return Optional.ofNullable(leashState.holderLocationOffset())
.orElse(leashState.defaultHolderLocationOffset());
}
+
/**
* 将局部偏移向量应用到实体旋转,返回世界坐标位置
- * @param entity 实体
- * @param localOffset 局部偏移(相对于实体局部坐标系)
+ *
+ * @param entity 实体
+ * @param localOffset 局部偏移(相对于实体局部坐标系)
* @param partialTicks 插值参数
- * @return 偏移旋转后的世界坐标位置
+ * @return 偏移旋转后的世界坐标位置 vec 3
*/
public static @NotNull Vec3 applyOffsetWithRotation(Entity entity, Vec3 localOffset, float partialTicks) {
// 实体中心位置
@@ -226,6 +240,11 @@ public class SuperLeashStateResolver {
/**
* 获取实体挂点位置,支持旋转偏移
+ *
+ * @param entity the entity
+ * @param baseOffset the base offset
+ * @param partialTicks the partial ticks
+ * @return the entity leash holder pos
*/
public static Vec3 getEntityLeashHolderPos(Entity entity, Vec3 baseOffset, float partialTicks) {
// 从眼睛位置(头部)开始
diff --git a/src/main/java/top/r3944realms/superleadrope/client/renderer/state/SuperLeashRenderState.java b/src/main/java/top/r3944realms/superleadrope/client/renderer/state/SuperLeashRenderState.java
index 46436a2..3c08537 100644
--- a/src/main/java/top/r3944realms/superleadrope/client/renderer/state/SuperLeashRenderState.java
+++ b/src/main/java/top/r3944realms/superleadrope/client/renderer/state/SuperLeashRenderState.java
@@ -18,6 +18,9 @@ package top.r3944realms.superleadrope.client.renderer.state;
import net.minecraft.core.BlockPos;
import net.minecraft.world.phys.Vec3;
+/**
+ * The type Super leash render state.
+ */
public record SuperLeashRenderState(
Vec3 startPos, // 当前帧起点位置
Vec3 endPos, // 当前帧终点位置
@@ -35,16 +38,26 @@ public record SuperLeashRenderState(
boolean isFirstPerson, // 是否是第一人称
BlockPos belowBlockPos // 持有者位置
) {
- // 预定义颜色常量
+ /**
+ * The constant COLOR_NORMAL.
+ */
+// 预定义颜色常量
public static final int COLOR_NORMAL = 0xFF6B4E2E; // 深棕色(木绳色,温暖自然)
+ /**
+ * The constant COLOR_TENSION.
+ */
public static final int COLOR_TENSION = 0xFFD9A066; // 黄色偏橙(张力稍高时微亮)
+ /**
+ * The constant COLOR_CRITICAL.
+ */
public static final int COLOR_CRITICAL = 0xFFB03A2E; // 暗红色(即将断裂,警告色)
/**
* 计算当前帧的摆动偏移量(用于波浪效果)
- * @param progress 沿绳子的进度(0.0-1.0)
+ *
+ * @param progress 沿绳子的进度(0.0-1.0)
* @param partialTicks 部分tick时间
- * @return 垂直于绳子方向的偏移向量
+ * @return 垂直于绳子方向的偏移向量 swing offset
*/
public Vec3 getSwingOffset(float progress, float partialTicks) {
// 基于正弦波的摆动效果
diff --git a/src/main/java/top/r3944realms/superleadrope/compat/CurtainCompat.java b/src/main/java/top/r3944realms/superleadrope/compat/CurtainCompat.java
index b1ccaaa..e1379cb 100644
--- a/src/main/java/top/r3944realms/superleadrope/compat/CurtainCompat.java
+++ b/src/main/java/top/r3944realms/superleadrope/compat/CurtainCompat.java
@@ -19,8 +19,21 @@ import dev.dubhe.curtain.features.player.patches.EntityPlayerMPFake;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.fml.ModList;
+/**
+ * The type Curtain compat.
+ */
public class CurtainCompat {
+ /**
+ * The constant isModLoaded.
+ */
public final static boolean isModLoaded = ModList.get().isLoaded("curtain");
+
+ /**
+ * Is not fake player boolean.
+ *
+ * @param player the player
+ * @return the boolean
+ */
public static boolean isNotFakePlayer(Player player) {
if (isModLoaded) {
return !(player instanceof EntityPlayerMPFake);
diff --git a/src/main/java/top/r3944realms/superleadrope/compat/jei/JEIPlugin.java b/src/main/java/top/r3944realms/superleadrope/compat/jei/JEIPlugin.java
index 3bb4bc4..d099ae7 100644
--- a/src/main/java/top/r3944realms/superleadrope/compat/jei/JEIPlugin.java
+++ b/src/main/java/top/r3944realms/superleadrope/compat/jei/JEIPlugin.java
@@ -21,6 +21,9 @@ import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;
import top.r3944realms.superleadrope.SuperLeadRope;
+/**
+ * The type Jei plugin.
+ */
@JeiPlugin
public class JEIPlugin implements IModPlugin {
private static final ResourceLocation UID = new ResourceLocation(SuperLeadRope.MOD_ID, "jei_plugin");
diff --git a/src/main/java/top/r3944realms/superleadrope/config/LeashCommonConfig.java b/src/main/java/top/r3944realms/superleadrope/config/LeashCommonConfig.java
index 8b7e693..95888bb 100644
--- a/src/main/java/top/r3944realms/superleadrope/config/LeashCommonConfig.java
+++ b/src/main/java/top/r3944realms/superleadrope/config/LeashCommonConfig.java
@@ -6,9 +6,21 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+/**
+ * The type Leash common config.
+ */
public class LeashCommonConfig {
+ /**
+ * The constant BUILDER.
+ */
public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
+ /**
+ * The constant SPEC.
+ */
public static final ForgeConfigSpec SPEC;
+ /**
+ * The constant COMMON.
+ */
public static final Common COMMON;
static {
@@ -17,38 +29,97 @@ public class LeashCommonConfig {
SPEC = BUILDER.build();
}
+ /**
+ * The type Common.
+ */
public static class Common {
- // Command
+ /**
+ * The Enable slp mod command prefix.
+ */
+// Command
public final ForgeConfigSpec.BooleanValue enableSLPModCommandPrefix;
+ /**
+ * The Slp mod command prefix.
+ */
public final ForgeConfigSpec.ConfigValue SLPModCommandPrefix;
- // Entity
+ /**
+ * The Teleport whitelist.
+ */
+// Entity
public final ForgeConfigSpec.ConfigValue> teleportWhitelist;
- // Leash settings
+ /**
+ * The Max leash length.
+ */
+// Leash settings
public final ForgeConfigSpec.DoubleValue maxLeashLength;
+ /**
+ * The Elastic distance scale.
+ */
public final ForgeConfigSpec.DoubleValue elasticDistanceScale;
+ /**
+ * The Extreme snap factor.
+ */
public final ForgeConfigSpec.DoubleValue extremeSnapFactor;
+ /**
+ * The Spring dampening.
+ */
public final ForgeConfigSpec.DoubleValue springDampening;
+ /**
+ * The Axis specific elasticity.
+ */
public final ForgeConfigSpec.ConfigValue> axisSpecificElasticity;
+ /**
+ * The Max leashes per entity.
+ */
public final ForgeConfigSpec.IntValue maxLeashesPerEntity;
- // True damping
+ /**
+ * The Enable true damping.
+ */
+// True damping
public final ForgeConfigSpec.BooleanValue enableTrueDamping;
+ /**
+ * The Damping factor.
+ */
public final ForgeConfigSpec.DoubleValue dampingFactor;
+ /**
+ * The Max force.
+ */
public final ForgeConfigSpec.DoubleValue maxForce;
+ /**
+ * The Player spring factor.
+ */
public final ForgeConfigSpec.DoubleValue playerSpringFactor;
+ /**
+ * The Mob spring factor.
+ */
public final ForgeConfigSpec.DoubleValue mobSpringFactor;
- // Leash state offsets
+ /**
+ * The Default apply entity location offset.
+ */
+// Leash state offsets
public final ForgeConfigSpec.ConfigValue> defaultApplyEntityLocationOffset;
+ /**
+ * The Default holder location offset.
+ */
public final ForgeConfigSpec.ConfigValue> defaultHolderLocationOffset;
- // 正则表达式模式
+ /**
+ * The constant OFFSET_PATTERN.
+ */
+// 正则表达式模式
static final Pattern OFFSET_PATTERN = Pattern.compile(
"(?i)(?:vec3|vec3d|vector3|offset)\\s*\\(\\s*([-+]?[0-9]*\\.?[0-9]+)\\s*,\\s*([-+]?[0-9]*\\.?[0-9]+)\\s*,\\s*([-+]?[0-9]*\\.?[0-9]+)\\s*\\)\\s*:\\s*\\[\\s*([^]]+?)\\s*]\\s*"
);
+ /**
+ * Instantiates a new Common.
+ *
+ * @param builder the builder
+ */
public Common(ForgeConfigSpec.Builder builder) {
// ===== Command =====
builder.push("Command");
diff --git a/src/main/java/top/r3944realms/superleadrope/config/LeashConfigManager.java b/src/main/java/top/r3944realms/superleadrope/config/LeashConfigManager.java
index 2157036..5a6581c 100644
--- a/src/main/java/top/r3944realms/superleadrope/config/LeashConfigManager.java
+++ b/src/main/java/top/r3944realms/superleadrope/config/LeashConfigManager.java
@@ -30,9 +30,18 @@ import java.util.regex.Matcher;
import static top.r3944realms.superleadrope.config.LeashCommonConfig.Common.OFFSET_PATTERN;
+/**
+ * The type Leash config manager.
+ */
public class LeashConfigManager {
- // ========== 最值检测 ==========
+ /**
+ * The constant MAX_DISTANCE_CHECK.
+ */
+// ========== 最值检测 ==========
public static final Predicate MAX_DISTANCE_CHECK = distance -> distance == null || (distance >= 6.0 && distance <= 256.0);
+ /**
+ * The constant ELASTIC_DISTANCE_CHECK.
+ */
public static final Predicate ELASTIC_DISTANCE_CHECK = distance -> distance == null || (distance >= 0.2 && distance <= 4.0);
// ========== 偏移映射 ==========
private final Map entityHolderMap = new ConcurrentHashMap<>();
@@ -60,6 +69,9 @@ public class LeashConfigManager {
private volatile List axisElasticity = List.of(0.8, 0.2, 0.8);
private volatile int maxLeashesPerEntity = 6;
+ /**
+ * Instantiates a new Leash config manager.
+ */
public LeashConfigManager() {
reloadAll();
}
@@ -102,6 +114,9 @@ public class LeashConfigManager {
);
}
+ /**
+ * Parse offset config.
+ */
public void parseOffsetConfig() {
Map> holder = parseOffsetList(LeashCommonConfig.COMMON.defaultHolderLocationOffset.get());
entityHolderMap.clear(); entityHolderMap.putAll(holder.get("entity"));
@@ -126,6 +141,12 @@ public class LeashConfigManager {
return modMap.getOrDefault("*", null);
}
+ /**
+ * Gets default entity offset.
+ *
+ * @param type the type
+ * @return the default entity offset
+ */
@SuppressWarnings({"DuplicatedCode", "deprecation"})
public Vec3 getDefaultEntityOffset(EntityType> type) {
String entityId = type.builtInRegistryHolder().key().location().toString();
@@ -137,6 +158,12 @@ public class LeashConfigManager {
return offset != null ? new Vec3(offset[0], offset[1], offset[2]) : Vec3.ZERO;
}
+ /**
+ * Gets default holder offset.
+ *
+ * @param type the type
+ * @return the default holder offset
+ */
@SuppressWarnings({"DuplicatedCode", "deprecation"})
public Vec3 getDefaultHolderOffset(EntityType> type) {
String entityId = type.builtInRegistryHolder().key().location().toString();
@@ -148,11 +175,36 @@ public class LeashConfigManager {
return offset != null ? new Vec3(offset[0], offset[1], offset[2]) : Vec3.ZERO;
}
+ /**
+ * Gets default entity offset.
+ *
+ * @param entity the entity
+ * @return the default entity offset
+ */
public Vec3 getDefaultEntityOffset(Entity entity) { return getDefaultEntityOffset(entity.getType()); }
+
+ /**
+ * Gets default holder offset.
+ *
+ * @param entity the entity
+ * @return the default holder offset
+ */
public Vec3 getDefaultHolderOffset(Entity entity) { return getDefaultHolderOffset(entity.getType()); }
- // ================== 白名单 ==================
+ /**
+ * Gets teleport whitelist.
+ *
+ * @return the teleport whitelist
+ */
+// ================== 白名单 ==================
public List getTeleportWhitelist() { return Collections.unmodifiableList(teleportWhitelistCache); }
+
+ /**
+ * Is entity teleport allowed boolean.
+ *
+ * @param type the type
+ * @return the boolean
+ */
@SuppressWarnings({"DuplicatedCode", "deprecation"})
public boolean isEntityTeleportAllowed(EntityType> type) {
String entityId = type.builtInRegistryHolder().key().location().toString();
@@ -173,36 +225,146 @@ public class LeashConfigManager {
return false;
}
+ /**
+ * Is entity teleport allowed boolean.
+ *
+ * @param entity the entity
+ * @return the boolean
+ */
public boolean isEntityTeleportAllowed(Entity entity) { return isEntityTeleportAllowed(entity.getType()); }
- // ================== 命令 ==================
+ /**
+ * Gets command prefix.
+ *
+ * @return the command prefix
+ */
+// ================== 命令 ==================
public String getCommandPrefix() { return commandPrefixCache; }
+
+ /**
+ * Is command prefix enabled boolean.
+ *
+ * @return the boolean
+ */
public boolean isCommandPrefixEnabled() { return commandPrefixEnabledCache; }
+
+ /**
+ * Gets full command.
+ *
+ * @param subCommand the sub command
+ * @return the full command
+ */
public String getFullCommand(String subCommand) {
return isCommandPrefixEnabled() ? getCommandPrefix() + " " + subCommand : subCommand;
}
- // ================== 拴绳物理参数 ==================
+ /**
+ * Is enable true damping boolean.
+ *
+ * @return the boolean
+ */
+// ================== 拴绳物理参数 ==================
public boolean isEnableTrueDamping() { return enableTrueDamping; }
+
+ /**
+ * Gets max force.
+ *
+ * @return the max force
+ */
public double getMaxForce() { return maxForce; }
+
+ /**
+ * Gets player spring factor.
+ *
+ * @return the player spring factor
+ */
public double getPlayerSpringFactor() { return playerSpringFactor; }
+
+ /**
+ * Gets mob spring factor.
+ *
+ * @return the mob spring factor
+ */
public double getMobSpringFactor() { return mobSpringFactor; }
+ /**
+ * Gets max leash length.
+ *
+ * @return the max leash length
+ */
public double getMaxLeashLength() { return maxLeashLength; }
+
+ /**
+ * Gets elastic distance scale.
+ *
+ * @return the elastic distance scale
+ */
public double getElasticDistanceScale() { return elasticDistanceScale; }
+
+ /**
+ * Gets extreme snap factor.
+ *
+ * @return the extreme snap factor
+ */
public double getExtremeSnapFactor() { return extremeSnapFactor; }
+
+ /**
+ * Gets spring dampening.
+ *
+ * @return the spring dampening
+ */
public double getSpringDampening() { return springDampening; }
+
+ /**
+ * Gets axis elasticity.
+ *
+ * @return the axis elasticity
+ */
public List getAxisElasticity() { return Collections.unmodifiableList(axisElasticity); }
+
+ /**
+ * Gets x elasticity.
+ *
+ * @return the x elasticity
+ */
public double getXElasticity() { return !axisElasticity.isEmpty() ? axisElasticity.get(0) : 0.8; }
+
+ /**
+ * Gets y elasticity.
+ *
+ * @return the y elasticity
+ */
public double getYElasticity() { return axisElasticity.size() > 1 ? axisElasticity.get(1) : 0.2; }
+
+ /**
+ * Gets z elasticity.
+ *
+ * @return the z elasticity
+ */
public double getZElasticity() { return axisElasticity.size() > 2 ? axisElasticity.get(2) : 0.8; }
+ /**
+ * Gets max leashes per entity.
+ *
+ * @return the max leashes per entity
+ */
public int getMaxLeashesPerEntity() { return maxLeashesPerEntity; }
+
+ /**
+ * Can entity accept more leashes boolean.
+ *
+ * @param entity the entity
+ * @param currentCount the current count
+ * @return the boolean
+ */
public boolean canEntityAcceptMoreLeashes(Entity entity, int currentCount) {
return currentCount < maxLeashesPerEntity;
}
- // ================== 管理 ==================
+ /**
+ * Reload all.
+ */
+// ================== 管理 ==================
public void reloadAll() {
parseOffsetConfig();
@@ -225,24 +387,47 @@ public class LeashConfigManager {
SuperLeadRope.logger.debug("Configs reloaded: {}", getStats());
}
+ /**
+ * Clear.
+ */
public void clear() {
entityHolderMap.clear(); tagHolderMap.clear(); modHolderMap.clear();
entityLeashMap.clear(); tagLeashMap.clear(); modLeashMap.clear();
teleportWhitelistCache = Collections.emptyList();
}
+ /**
+ * Loading.
+ *
+ * @param manager the manager
+ */
public static void loading(LeashConfigManager manager) {
manager.reloadAll();
}
+ /**
+ * Reloading.
+ *
+ * @param manager the manager
+ */
public static void reloading(LeashConfigManager manager) {
manager.reloadAll();
}
+ /**
+ * Unloading.
+ *
+ * @param manager the manager
+ */
public static void unloading(LeashConfigManager manager) {
if(manager != null) manager.clear();
}
+ /**
+ * Gets stats.
+ *
+ * @return the stats
+ */
public String getStats() {
return String.format(
"Holder: Entities: %d, Tags: %d, Mods: %d\nLeash: Entities: %d, Tags: %d, Mods: %d, TeleportWhitelist: %d",
diff --git a/src/main/java/top/r3944realms/superleadrope/content/SLPDamageTypes.java b/src/main/java/top/r3944realms/superleadrope/content/SLPDamageTypes.java
index fa88264..0bb9f5d 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/SLPDamageTypes.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/SLPDamageTypes.java
@@ -20,8 +20,14 @@ import net.minecraft.world.damagesource.DamageScaling;
import net.minecraft.world.damagesource.DamageType;
import net.minecraft.world.damagesource.DeathMessageType;
+/**
+ * The type Slp damage types.
+ */
public class SLPDamageTypes {
- // 非绑定主人使用惩罚
+ /**
+ * The constant ETERNAL_POTATO_NOT_OWNER.
+ */
+// 非绑定主人使用惩罚
public static final DamageType ETERNAL_POTATO_NOT_OWNER =
new DamageType(
"eternal_potato_not_owner",
@@ -30,6 +36,9 @@ public class SLPDamageTypes {
DamageEffects.HURT,
DeathMessageType.DEFAULT
);
+ /**
+ * The constant ETERNAL_POTATO_NOT_COMPLETE.
+ */
public static final DamageType ETERNAL_POTATO_NOT_COMPLETE =
new DamageType(
"eternal_potato_not_complete",
diff --git a/src/main/java/top/r3944realms/superleadrope/content/SLPTags.java b/src/main/java/top/r3944realms/superleadrope/content/SLPTags.java
index 76ff589..4463b00 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/SLPTags.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/SLPTags.java
@@ -21,8 +21,17 @@ import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import top.r3944realms.superleadrope.SuperLeadRope;
+/**
+ * The type Slp tags.
+ */
public class SLPTags {
+ /**
+ * The type Items.
+ */
public static class Items {
+ /**
+ * The constant LEAD.
+ */
public static final TagKey- LEAD = tag("lead");
private static TagKey tag(String name)
{
diff --git a/src/main/java/top/r3944realms/superleadrope/content/SLPToolTier.java b/src/main/java/top/r3944realms/superleadrope/content/SLPToolTier.java
index b6a4f3e..049571e 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/SLPToolTier.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/SLPToolTier.java
@@ -21,7 +21,13 @@ import org.jetbrains.annotations.NotNull;
import java.util.function.Supplier;
+/**
+ * The enum Slp tool tier.
+ */
public enum SLPToolTier implements Tier {
+ /**
+ * String slp tool tier.
+ */
STRING(24, 1.0F, 0.0F, 15, () -> Ingredient.of(SLPTags.Items.LEAD))
;
private final int uses;
diff --git a/src/main/java/top/r3944realms/superleadrope/content/capability/CapabilityHandler.java b/src/main/java/top/r3944realms/superleadrope/content/capability/CapabilityHandler.java
index 76c04e8..77388cb 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/capability/CapabilityHandler.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/capability/CapabilityHandler.java
@@ -32,14 +32,31 @@ import top.r3944realms.superleadrope.content.capability.provider.LeashDataProvid
import top.r3944realms.superleadrope.content.capability.provider.LeashStateProvider;
import top.r3944realms.superleadrope.content.item.EternalPotatoItem;
+/**
+ * The type Capability handler.
+ */
public class CapabilityHandler {
+ /**
+ * The constant ETERNAL_POTATO_CAP.
+ */
public static final Capability ETERNAL_POTATO_CAP = CapabilityManager.get(new CapabilityToken<>() {});
+
+ /**
+ * Register capability.
+ *
+ * @param event the event
+ */
public static void registerCapability(@NotNull RegisterCapabilitiesEvent event) {
event.register(ILeashData.class);
event.register(IEternalPotato.class);
event.register(ILeashState.class);
}
+ /**
+ * Attach capability.
+ *
+ * @param event the event
+ */
public static void attachCapability(@NotNull AttachCapabilitiesEvent> event) {
Object object = event.getObject();
if(object instanceof Entity entity &&
diff --git a/src/main/java/top/r3944realms/superleadrope/content/capability/CapabilityRemainder.java b/src/main/java/top/r3944realms/superleadrope/content/capability/CapabilityRemainder.java
index 81c1697..b09f73f 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/capability/CapabilityRemainder.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/capability/CapabilityRemainder.java
@@ -20,7 +20,15 @@ import net.minecraft.world.entity.player.Player;
import net.minecraftforge.event.entity.player.PlayerEvent;
import top.r3944realms.superleadrope.util.capability.LeashStateInnerAPI;
+/**
+ * The type Capability remainder.
+ */
public class CapabilityRemainder {
+ /**
+ * On player clone.
+ *
+ * @param event the event
+ */
public static void onPlayerClone(PlayerEvent.Clone event) {
Player newEntity = event.getEntity();
if(newEntity instanceof ServerPlayer newPlayer) {
diff --git a/src/main/java/top/r3944realms/superleadrope/content/capability/impi/EternalPotatoImpl.java b/src/main/java/top/r3944realms/superleadrope/content/capability/impi/EternalPotatoImpl.java
index 39d75db..098bc37 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/capability/impi/EternalPotatoImpl.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/capability/impi/EternalPotatoImpl.java
@@ -29,6 +29,9 @@ import top.r3944realms.superleadrope.network.toClient.EternalPotatoSyncCapPacket
import java.util.UUID;
+/**
+ * The type Eternal potato.
+ */
public class EternalPotatoImpl implements IEternalPotato {
private ItemStackSync itemStackSync;
private Player boundPlayer;
@@ -51,18 +54,54 @@ public class EternalPotatoImpl implements IEternalPotato {
private PunishmentDefinition punishment = PunishmentDefinition.DEFAULT;
private IObligationCompletion completionRule = IObligationCompletion.NONE;
- // NBT Keys
+ /**
+ * The constant TAG_LAST_PUNISH_DATE.
+ */
+// NBT Keys
public static final String TAG_LAST_PUNISH_DATE = "last_punish_date";
+ /**
+ * The constant TAG_PENDING_PUNISHMENTS.
+ */
public static final String TAG_PENDING_PUNISHMENTS = "pending_punishments";
+ /**
+ * The constant TAG_GRACE_PERIOD.
+ */
public static final String TAG_GRACE_PERIOD = "grace_period";
+ /**
+ * The constant TAG_OWNER_UUID.
+ */
public static final String TAG_OWNER_UUID = "owner_uuid";
+ /**
+ * The constant TAG_ITEM_UUID.
+ */
public static final String TAG_ITEM_UUID = "item_uuid";
+ /**
+ * The constant TAG_OWNER_NAME.
+ */
public static final String TAG_OWNER_NAME = "owner_name";
+ /**
+ * The constant TAG_OBLIGATIONS.
+ */
public static final String TAG_OBLIGATIONS = "obligations";
+ /**
+ * The constant TAG_LAST_RESET.
+ */
public static final String TAG_LAST_RESET = "last_reset";
+ /**
+ * The constant TAG_PUNISHMENT_TYPE.
+ */
public static final String TAG_PUNISHMENT_TYPE = "punishment_type";
+ /**
+ * The constant TAG_PUNISHMENT_STRENGTH.
+ */
public static final String TAG_PUNISHMENT_STRENGTH = "punishment_strength";
+ /**
+ * The constant TAG_PUNISHMENT_AFFECT_OTHERS.
+ */
public static final String TAG_PUNISHMENT_AFFECT_OTHERS = "punishment_affect_others";
+ /**
+ * The constant TAG_COMPLETION_ID.
+ */
public static final String TAG_COMPLETION_ID = "completion_id";
@Override
diff --git a/src/main/java/top/r3944realms/superleadrope/content/capability/impi/LeashDataImpl.java b/src/main/java/top/r3944realms/superleadrope/content/capability/impi/LeashDataImpl.java
index 68c7f1a..dc692d6 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/capability/impi/LeashDataImpl.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/capability/impi/LeashDataImpl.java
@@ -104,6 +104,11 @@ public class LeashDataImpl implements ILeashData {
// 引入解决 绳结不保存导致第二进入持有者不存在的问题
private final Map leashKnots = new ConcurrentHashMap<>();
+ /**
+ * Instantiates a new Leash data.
+ *
+ * @param entity the entity
+ */
public LeashDataImpl(Entity entity) {
this.entity = entity;
}
@@ -153,6 +158,11 @@ public class LeashDataImpl implements ILeashData {
needsSync = false;
}
+ @Override
+ public Entity self() {
+ return entity;
+ }
+
@Override
public @Nullable Double getStaticMaxDistance() {
return staticMaxDistance;
@@ -399,6 +409,13 @@ public class LeashDataImpl implements ILeashData {
old.maxKeepLeashTicks()
));
}
+
+ /**
+ * Sets max distance inner.
+ *
+ * @param holderUUID the holder uuid
+ * @param newMaxDistance the new max distance
+ */
@SuppressWarnings("OptionalGetWithoutIsPresent")
public void setMaxDistanceInner(UUID holderUUID, @Nullable Double newMaxDistance) {
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return;
@@ -466,6 +483,12 @@ public class LeashDataImpl implements ILeashData {
));
}
+ /**
+ * Sets max distance inner.
+ *
+ * @param knotPos the knot pos
+ * @param newMaxDistance the new max distance
+ */
@SuppressWarnings("OptionalGetWithoutIsPresent")
public void setMaxDistanceInner(BlockPos knotPos, @Nullable Double newMaxDistance) {
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return;
@@ -540,6 +563,13 @@ public class LeashDataImpl implements ILeashData {
old.maxKeepLeashTicks()
));
}
+
+ /**
+ * Sets elastic distance scale inner.
+ *
+ * @param holderUUID the holder uuid
+ * @param scale the scale
+ */
@SuppressWarnings("OptionalGetWithoutIsPresent")
public void setElasticDistanceScaleInner(UUID holderUUID, @Nullable Double scale) {
if (!LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(scale)) return;
@@ -572,6 +602,13 @@ public class LeashDataImpl implements ILeashData {
old.maxKeepLeashTicks()
));
}
+
+ /**
+ * Sets elastic distance scale inner.
+ *
+ * @param knotPos the knot pos
+ * @param scale the scale
+ */
@SuppressWarnings("OptionalGetWithoutIsPresent")
public void setElasticDistanceScaleInner(BlockPos knotPos, @Nullable Double scale) {
if (!LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(scale)) return;
@@ -1145,7 +1182,13 @@ public class LeashDataImpl implements ILeashData {
return !leashHolders.isEmpty();
}
- //只能系在这些实体上,在这里,其它情况一律忽略
+ /**
+ * Is leashable boolean.
+ *
+ * @param entity the entity
+ * @return the boolean
+ */
+//只能系在这些实体上,在这里,其它情况一律忽略
//TODO: 未来更新计划 - 标签支持控制
public static boolean isLeashable(Entity entity) {
return entity instanceof LivingEntity || entity instanceof Boat || entity instanceof AbstractMinecart;
diff --git a/src/main/java/top/r3944realms/superleadrope/content/capability/impi/LeashStateImpl.java b/src/main/java/top/r3944realms/superleadrope/content/capability/impi/LeashStateImpl.java
index b987d93..8e00e40 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/capability/impi/LeashStateImpl.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/capability/impi/LeashStateImpl.java
@@ -40,6 +40,10 @@ import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+
+/**
+ * The type Leash state.
+ */
//TODO: 将拴绳状态与数据联系在一起
public class LeashStateImpl implements ILeashState {
private Entity entity;
@@ -50,6 +54,13 @@ public class LeashStateImpl implements ILeashState {
@Nullable
private volatile Vec3 staticApplyEntityLocationOffset;
private volatile Vec3 defaultApplyEntityLocationOffset;
+
+ /**
+ * Instantiates a new Leash state.
+ *
+ * @param entity the entity
+ * @param defaultApplyEntityLocationOffset the default apply entity location offset
+ */
public LeashStateImpl(Entity entity, Vec3 defaultApplyEntityLocationOffset) {
this.entity = entity;
this.defaultApplyEntityLocationOffset = defaultApplyEntityLocationOffset;
@@ -91,6 +102,11 @@ public class LeashStateImpl implements ILeashState {
needsSync = false;
}
+ @Override
+ public Entity self() {
+ return entity;
+ }
+
@Override
public boolean hasLeashState() {
return !leashKnots.isEmpty() || !leashHolders.isEmpty();
diff --git a/src/main/java/top/r3944realms/superleadrope/content/capability/inter/IEternalPotato.java b/src/main/java/top/r3944realms/superleadrope/content/capability/inter/IEternalPotato.java
index e7a8ac2..db02b95 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/capability/inter/IEternalPotato.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/capability/inter/IEternalPotato.java
@@ -23,64 +23,240 @@ import top.r3944realms.superleadrope.core.punishment.PunishmentDefinition;
import java.util.UUID;
+/**
+ * The interface Eternal potato.
+ */
public interface IEternalPotato {
+ /**
+ * The interface Item stack sync.
+ */
interface ItemStackSync {
+ /**
+ * Mark dirty for item.
+ */
void markDirtyForItem();
}
+
+ /**
+ * Bind item stack sync.
+ *
+ * @param callback the callback
+ */
void bindItemStackSync(ItemStackSync callback);
+
+ /**
+ * Begin init.
+ */
void beginInit();
+
+ /**
+ * End init.
+ */
void endInit();
+ /**
+ * Sets item uuid.
+ *
+ * @param uuid the uuid
+ */
void setItemUUID(UUID uuid);
+
+ /**
+ * Gets item uuid.
+ *
+ * @return the item uuid
+ */
UUID getItemUUID();
+
+ /**
+ * Sets owner.
+ *
+ * @param uuid the uuid
+ * @param name the name
+ */
void setOwner(UUID uuid, String name);
+
+ /**
+ * Gets owner uuid.
+ *
+ * @return the owner uuid
+ */
UUID getOwnerUUID();
+
+ /**
+ * Gets owner name.
+ *
+ * @return the owner name
+ */
String getOwnerName();
+ /**
+ * Sets daily obligations.
+ *
+ * @param count the count
+ */
void setDailyObligations(int count);
+
+ /**
+ * Gets daily obligations.
+ *
+ * @return the daily obligations
+ */
int getDailyObligations();
+ /**
+ * Gets pending punishments.
+ *
+ * @return the pending punishments
+ */
int getPendingPunishments();
+
+ /**
+ * Sets pending punishments.
+ *
+ * @param count the count
+ */
void setPendingPunishments(int count);
+
/**
* 计算今日总任务次数 = 未完成惩罚次数 + 当日剩余次数
+ *
+ * @return the final task count
*/
default int getFinalTaskCount() {
return getPendingPunishments() + getDailyObligations();
}
+
+ /**
+ * Is network sync non required boolean.
+ *
+ * @return the boolean
+ */
default boolean isNetworkSyncNonRequired() {
return !EternalPotatoFacade.isServer();
}
+
+ /**
+ * Is global effect boolean.
+ *
+ * @return the boolean
+ */
default boolean isGlobalEffect() {
// 根据当前惩罚、任务规则决定
return getPunishment() != null && getPunishment().affectOthers();
}
+
/**
* 是否在宽限期内
+ *
+ * @return the boolean
*/
default boolean isWithinGracePeriod() {
return getPendingPunishments() <= getGracePunishments();
}
+
/**
* 宽限惩罚数
+ *
+ * @return the grace punishments
*/
int getGracePunishments();
+
+ /**
+ * Sets grace punishments.
+ *
+ * @param count the count
+ */
void setGracePunishments(int count);
+
+ /**
+ * Sync to client.
+ *
+ * @param player the player
+ */
void syncToClient(Player player);
+
+ /**
+ * Bind sync context.
+ *
+ * @param player the player
+ */
void bindSyncContext(Player player);
+
+ /**
+ * Gets bound player.
+ *
+ * @return the bound player
+ */
Player getBoundPlayer();
+
+ /**
+ * Sets last reset.
+ *
+ * @param date the date
+ */
void setLastReset(String date);
+
+ /**
+ * Gets last reset.
+ *
+ * @return the last reset
+ */
String getLastReset();
+ /**
+ * Gets punishment.
+ *
+ * @return the punishment
+ */
PunishmentDefinition getPunishment();
+
+ /**
+ * Sets punishment.
+ *
+ * @param definition the definition
+ */
void setPunishment(PunishmentDefinition definition);
+ /**
+ * Sets last punish date.
+ *
+ * @param date the date
+ */
void setLastPunishDate(String date);
+
+ /**
+ * Gets last punish date.
+ *
+ * @return the last punish date
+ */
String getLastPunishDate();
+ /**
+ * Gets completion rule.
+ *
+ * @return the completion rule
+ */
IObligationCompletion getCompletionRule();
+
+ /**
+ * Sets completion rule.
+ *
+ * @param completion the completion
+ */
void setCompletionRule(IObligationCompletion completion);
+ /**
+ * Serialize nbt compound tag.
+ *
+ * @return the compound tag
+ */
CompoundTag serializeNBT();
+
+ /**
+ * Deserialize nbt.
+ *
+ * @param nbt the nbt
+ */
void deserializeNBT(CompoundTag nbt);
}
diff --git a/src/main/java/top/r3944realms/superleadrope/content/capability/provider/EternalPotatoProvider.java b/src/main/java/top/r3944realms/superleadrope/content/capability/provider/EternalPotatoProvider.java
index 3534094..240efa8 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/capability/provider/EternalPotatoProvider.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/capability/provider/EternalPotatoProvider.java
@@ -32,8 +32,14 @@ import top.r3944realms.superleadrope.core.potato.EternalPotatoFacade;
import java.util.UUID;
+/**
+ * The type Eternal potato provider.
+ */
public class EternalPotatoProvider implements ICapabilitySerializable {
+ /**
+ * The constant ETERNAL_POTATO_DATA_REL.
+ */
public static final ResourceLocation ETERNAL_POTATO_DATA_REL =
new ResourceLocation(SuperLeadRope.MOD_ID, "eternal_potato_data");
@@ -44,6 +50,11 @@ public class EternalPotatoProvider implements ICapabilitySerializable {
+ /**
+ * The constant LEASH_DATA_REL.
+ */
public static final ResourceLocation LEASH_DATA_REL = new ResourceLocation(SuperLeadRope.MOD_ID, "leash_data");
private final ILeashData instance;
private final LazyOptional optional;
+
+ /**
+ * Instantiates a new Leash data provider.
+ *
+ * @param entity the entity
+ */
public LeashDataProvider(Entity entity) {
this.instance = new LeashDataImpl(entity);
this.optional = LazyOptional.of(() -> instance);
diff --git a/src/main/java/top/r3944realms/superleadrope/content/capability/provider/LeashStateProvider.java b/src/main/java/top/r3944realms/superleadrope/content/capability/provider/LeashStateProvider.java
index ccdd2c9..82105ae 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/capability/provider/LeashStateProvider.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/capability/provider/LeashStateProvider.java
@@ -30,10 +30,22 @@ import top.r3944realms.superleadrope.api.SLPCapability;
import top.r3944realms.superleadrope.api.type.capabilty.ILeashState;
import top.r3944realms.superleadrope.content.capability.impi.LeashStateImpl;
+/**
+ * The type Leash state provider.
+ */
public class LeashStateProvider implements ICapabilitySerializable {
+ /**
+ * The constant LEASH_STATE_REL.
+ */
public static final ResourceLocation LEASH_STATE_REL = new ResourceLocation(SuperLeadRope.MOD_ID, "leash_state");
private final ILeashState instance;
private final LazyOptional optional;
+
+ /**
+ * Instantiates a new Leash state provider.
+ *
+ * @param entity the entity
+ */
public LeashStateProvider(Entity entity) {
this.instance = new LeashStateImpl(entity, CommonEventHandler.leashConfigManager.getDefaultEntityOffset(entity));
this.optional = LazyOptional.of(() -> instance);
diff --git a/src/main/java/top/r3944realms/superleadrope/content/command/Command.java b/src/main/java/top/r3944realms/superleadrope/content/command/Command.java
index 3ecc7f3..f5b8433 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/command/Command.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/command/Command.java
@@ -23,9 +23,27 @@ import top.r3944realms.superleadrope.CommonEventHandler;
import java.util.List;
+/**
+ * The type Command.
+ */
public class Command {
+ /**
+ * The constant PREFIX.
+ */
public static final String PREFIX = CommonEventHandler.leashConfigManager.getCommandPrefix();
+ /**
+ * The constant SHOULD_USE_PREFIX.
+ */
public static boolean SHOULD_USE_PREFIX = CommonEventHandler.leashConfigManager.isCommandPrefixEnabled();
+
+ /**
+ * Gets liter argument builder of css.
+ *
+ * @param name the name
+ * @param shouldAddToList the should add to list
+ * @param list the list
+ * @return the liter argument builder of css
+ */
static LiteralArgumentBuilder getLiterArgumentBuilderOfCSS(String name, boolean shouldAddToList, @Nullable List> list) {
LiteralArgumentBuilder literal = Commands.literal(name);
if (shouldAddToList) {
diff --git a/src/main/java/top/r3944realms/superleadrope/content/command/LeashDataCommand.java b/src/main/java/top/r3944realms/superleadrope/content/command/LeashDataCommand.java
index d6e1343..f1872ba 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/command/LeashDataCommand.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/command/LeashDataCommand.java
@@ -47,18 +47,58 @@ import java.util.List;
import java.util.Optional;
import static top.r3944realms.superleadrope.content.command.Command.*;
+
+/**
+ * The type Leash data command.
+ */
public class LeashDataCommand {
+ /**
+ * The constant SLP_LEASH_MESSAGE_.
+ */
public static final String SLP_LEASH_MESSAGE_ = SuperLeadRope.MOD_ID + ".command.leash.message.";
+ /**
+ * The constant LEASH_DATA_GET_.
+ */
public static final String LEASH_DATA_GET_ = SLP_LEASH_MESSAGE_ + ".get.",
- TITLE = LEASH_DATA_GET_ + "title",
- TOTAL = LEASH_DATA_GET_ + "total",
- BLOCK = LEASH_DATA_GET_ + "block",
- UUID = LEASH_DATA_GET_ + "uuid",
- MAX = LEASH_DATA_GET_ + "max",
- ELASTIC = LEASH_DATA_GET_ + "elastic",
- KEEP = LEASH_DATA_GET_ + "keep",
- RESERVED = LEASH_DATA_GET_ + "reserved"
+ /**
+ * The Title.
+ */
+ TITLE = LEASH_DATA_GET_ + "title",
+ /**
+ * The Total.
+ */
+ TOTAL = LEASH_DATA_GET_ + "total",
+ /**
+ * The Block.
+ */
+ BLOCK = LEASH_DATA_GET_ + "block",
+ /**
+ * The Uuid.
+ */
+ UUID = LEASH_DATA_GET_ + "uuid",
+ /**
+ * The Max.
+ */
+ MAX = LEASH_DATA_GET_ + "max",
+ /**
+ * The Elastic.
+ */
+ ELASTIC = LEASH_DATA_GET_ + "elastic",
+ /**
+ * The Keep.
+ */
+ KEEP = LEASH_DATA_GET_ + "keep",
+ /**
+ * The Reserved.
+ */
+ RESERVED = LEASH_DATA_GET_ + "reserved"
;
+
+ /**
+ * Register.
+ *
+ * @param dispatcher the dispatcher
+ */
public static void register(CommandDispatcher dispatcher) {
@Nullable List> nodeList = SHOULD_USE_PREFIX ? null : new ArrayList<>();
LiteralArgumentBuilder literalArgumentBuilder = Commands.literal(PREFIX);
@@ -283,6 +323,10 @@ public class LeashDataCommand {
}
}
}
+
+ /**
+ * The constant SET_MAX_DISTANCE.
+ */
public static final String SET_MAX_DISTANCE = SLP_LEASH_MESSAGE_ + "set_apply_entity.max_distance";
private static int setMaxDistance(CommandContext context) throws CommandSyntaxException {
return setMaxDistance(context, CommonEventHandler.leashConfigManager.getMaxLeashLength(), "");
@@ -298,14 +342,26 @@ public class LeashDataCommand {
}
return -1;
}
+
+ /**
+ * The constant REMOVE_ALL_BLOCK_LEASHES.
+ */
public static final String REMOVE_ALL_BLOCK_LEASHES = SLP_LEASH_MESSAGE_ + "remove_apply_entity.all_block_leashes";
private static int removeAllBlockLeashes(CommandContext context) throws CommandSyntaxException {
return -1;
}
+
+ /**
+ * The constant REMOVE_ALL_HOLDER_LEASHES.
+ */
public static final String REMOVE_ALL_HOLDER_LEASHES = SLP_LEASH_MESSAGE_ + "remove_apply_entity.all_holder_leashes";
private static int removeAllHolderLeashes(CommandContext context) throws CommandSyntaxException {
return -1;
}
+
+ /**
+ * The constant TRANSFER_FROM_BLOCK.
+ */
public static final String TRANSFER_FROM_BLOCK = SLP_LEASH_MESSAGE_ + "transfer.from_block";
private static int transferFromBlock(CommandContext context) throws CommandSyntaxException {
return transferFromBlock(context, "");
@@ -313,6 +369,10 @@ public class LeashDataCommand {
private static int transferFromBlock(CommandContext context, String reserved) throws CommandSyntaxException {
return -1;
}
+
+ /**
+ * The constant SET_ELASTIC_DISTANCE.
+ */
public static final String SET_ELASTIC_DISTANCE = SLP_LEASH_MESSAGE_ + "set_apply_entity.elastic_distance";
private static int setElasticDistance(CommandContext context) throws CommandSyntaxException {
return setElasticDistance(context, 0 ,"");
@@ -323,6 +383,10 @@ public class LeashDataCommand {
private static int setElasticDistance(CommandContext context, int keepTicks, String reserved) throws CommandSyntaxException {
return -1;
}
+
+ /**
+ * The constant SET_BLOCK_MAX_DISTANCE.
+ */
public static final String SET_BLOCK_MAX_DISTANCE = SLP_LEASH_MESSAGE_ + "set_apply_entity.block_max_distance";
private static int setBlockMaxDistance(CommandContext context) throws CommandSyntaxException {
return setBlockMaxDistance(context, 0 ,"");
@@ -333,6 +397,10 @@ public class LeashDataCommand {
private static int setBlockMaxDistance(CommandContext context, int keepTicks, String reserved) throws CommandSyntaxException {
return -1;
}
+
+ /**
+ * The constant SET_BLOCK_ELASTIC_DISTANCE.
+ */
public static final String SET_BLOCK_ELASTIC_DISTANCE = SLP_LEASH_MESSAGE_ + "set_apply_entity.block_elastic_distance";
private static int setBlockElasticDistance(CommandContext context) throws CommandSyntaxException {
return setBlockElasticDistance(context, 0 ,"");
diff --git a/src/main/java/top/r3944realms/superleadrope/content/command/LeashStateCommand.java b/src/main/java/top/r3944realms/superleadrope/content/command/LeashStateCommand.java
index 5079bb0..c0c900d 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/command/LeashStateCommand.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/command/LeashStateCommand.java
@@ -18,8 +18,16 @@ package top.r3944realms.superleadrope.content.command;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.commands.CommandSourceStack;
+/**
+ * The type Leash state command.
+ */
public class LeashStateCommand {
- // 获取State
+ /**
+ * Register.
+ *
+ * @param dispatcher the dispatcher
+ */
+// 获取State
// 设置State
// Holder>
// 设置对应目标的 拴绳偏移
diff --git a/src/main/java/top/r3944realms/superleadrope/content/command/MotionCommand.java b/src/main/java/top/r3944realms/superleadrope/content/command/MotionCommand.java
index ad447ba..bf33433 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/command/MotionCommand.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/command/MotionCommand.java
@@ -37,11 +37,29 @@ import java.util.List;
import static top.r3944realms.superleadrope.content.command.Command.*;
+/**
+ * The type Motion command.
+ */
public class MotionCommand {
private final static String SLP_MOTION_MESSAGE_ = SuperLeadRope.MOD_ID + ".command.motion.message.";
+ /**
+ * The constant MOTION_SETTER_SUCCESSFUL.
+ */
public final static String MOTION_SETTER_SUCCESSFUL = SLP_MOTION_MESSAGE_ + "setter.successful",
- MOTION_ADDER_SUCCESSFUL = SLP_MOTION_MESSAGE_ + "adder.successful",
- MOTION_MULTIPLY_SUCCESSFUL = SLP_MOTION_MESSAGE_ + "multiply.successful";
+ /**
+ * The Motion adder successful.
+ */
+ MOTION_ADDER_SUCCESSFUL = SLP_MOTION_MESSAGE_ + "adder.successful",
+ /**
+ * The Motion multiply successful.
+ */
+ MOTION_MULTIPLY_SUCCESSFUL = SLP_MOTION_MESSAGE_ + "multiply.successful";
+
+ /**
+ * Register.
+ *
+ * @param dispatcher the dispatcher
+ */
public static void register(CommandDispatcher dispatcher) {
@Nullable List> nodeList = SHOULD_USE_PREFIX ? null : new ArrayList<>();
LiteralArgumentBuilder literalArgumentBuilder = Commands.literal(PREFIX);
diff --git a/src/main/java/top/r3944realms/superleadrope/content/entity/SuperLeashKnotEntity.java b/src/main/java/top/r3944realms/superleadrope/content/entity/SuperLeashKnotEntity.java
index 8f13555..2895f23 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/entity/SuperLeashKnotEntity.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/entity/SuperLeashKnotEntity.java
@@ -43,6 +43,9 @@ import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
+/**
+ * The type Super leash knot entity.
+ */
public class SuperLeashKnotEntity extends LeashFenceKnotEntity {
// 默认尺寸
private static final float DEFAULT_WIDTH = 0.5f;
@@ -58,11 +61,23 @@ public class SuperLeashKnotEntity extends LeashFenceKnotEntity {
BlockTags.WALLS
);
+ /**
+ * Instantiates a new Super leash knot entity.
+ *
+ * @param pEntityType the p entity type
+ * @param pLevel the p level
+ */
public SuperLeashKnotEntity(EntityType extends SuperLeashKnotEntity> pEntityType, Level pLevel) {
super(pEntityType, pLevel);
}
+ /**
+ * Instantiates a new Super leash knot entity.
+ *
+ * @param pLevel the p level
+ * @param pPos the p pos
+ */
public SuperLeashKnotEntity(Level pLevel, BlockPos pPos) {
this(SLPEntityTypes.SUPER_LEAD_KNOT.get(), pLevel);
this.setPos(pPos.getX(), pPos.getY(), pPos.getZ());
@@ -103,6 +118,13 @@ public class SuperLeashKnotEntity extends LeashFenceKnotEntity {
return supportBlock;
}
+ /**
+ * Gets or create knot.
+ *
+ * @param pLevel the p level
+ * @param pPos the p pos
+ * @return the or create knot
+ */
public static @NotNull SuperLeashKnotEntity getOrCreateKnot(@NotNull Level pLevel, @NotNull BlockPos pPos) {
int i = pPos.getX();
int j = pPos.getY();
@@ -126,6 +148,14 @@ public class SuperLeashKnotEntity extends LeashFenceKnotEntity {
pLevel.addFreshEntity(superLeashKnotEntity1);
return superLeashKnotEntity1;
}
+
+ /**
+ * Get optional.
+ *
+ * @param level the level
+ * @param pos the pos
+ * @return the optional
+ */
public static @NotNull Optional get(@NotNull Level level, @NotNull BlockPos pos) {
AABB searchArea = new AABB(pos).inflate(1.0D);
@@ -137,7 +167,11 @@ public class SuperLeashKnotEntity extends LeashFenceKnotEntity {
/**
* 创建拴绳结,请不用直接调用这个,除非你知道自己在干上面
- * @return 拴绳结
+ *
+ * @param pLevel the p level
+ * @param pPos the p pos
+ * @param isEmpty the is empty
+ * @return 拴绳结 super leash knot entity
*/
public static @NotNull SuperLeashKnotEntity createKnot(@NotNull Level pLevel, @NotNull BlockPos pPos, boolean isEmpty) {
if(isEmpty) {
@@ -179,6 +213,12 @@ public class SuperLeashKnotEntity extends LeashFenceKnotEntity {
//TODO: 未来扩展可配置化大小
}
+ /**
+ * Is support block boolean.
+ *
+ * @param state the state
+ * @return the boolean
+ */
public static boolean isSupportBlock(BlockState state) {
for(TagKey tagKey : SUPPORTED_BLOCK) {
if(state.is(tagKey)) {
diff --git a/src/main/java/top/r3944realms/superleadrope/content/gamerule/SLPGamerules.java b/src/main/java/top/r3944realms/superleadrope/content/gamerule/SLPGamerules.java
index 5751f2e..05b2e98 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/gamerule/SLPGamerules.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/gamerule/SLPGamerules.java
@@ -19,25 +19,77 @@ import top.r3944realms.superleadrope.core.register.SLPGameruleRegistry;
import java.util.HashMap;
+/**
+ * The type Slp gamerules.
+ */
public class SLPGamerules {
+ /**
+ * The constant GAMERULE_PREFIX.
+ */
public static final String GAMERULE_PREFIX = "SLP.";
+ /**
+ * The constant GAMERULE_REGISTRY.
+ */
public static final SLPGameruleRegistry GAMERULE_REGISTRY = SLPGameruleRegistry.INSTANCE;
+ /**
+ * The constant gamerulesBooleanValuesClient.
+ */
public static final HashMap gamerulesBooleanValuesClient = new HashMap<>();
+ /**
+ * The constant gameruleIntegerValuesClient.
+ */
public static final HashMap gameruleIntegerValuesClient = new HashMap<>();
+ /**
+ * The constant RULE_KEY_PERFiX_.
+ */
public static final String RULE_KEY_PERFiX_ = "gamerule." + GAMERULE_PREFIX;
+
+ /**
+ * Gets description key.
+ *
+ * @param gameRuleClass the game rule class
+ * @return the description key
+ */
public static String getDescriptionKey(Class> gameRuleClass) {
return RULE_KEY_PERFiX_ + gameRuleClass.getSimpleName() + ".description";
}
+
+ /**
+ * Gets description key.
+ *
+ * @param gameRuleName the game rule name
+ * @return the description key
+ */
public static String getDescriptionKey(String gameRuleName) {
return RULE_KEY_PERFiX_ + gameRuleName + ".description";
}
+
+ /**
+ * Gets gamerule name.
+ *
+ * @param clazz the clazz
+ * @return the gamerule name
+ */
public static String getGameruleName(Class> clazz) {
return SLPGamerules.GAMERULE_PREFIX + clazz.getSimpleName();
}
+
+ /**
+ * Gets gamerule name.
+ *
+ * @param gamerulesName the gamerules name
+ * @return the gamerule name
+ */
public static String getGameruleName(String gamerulesName) {
return SLPGamerules.GAMERULE_PREFIX + gamerulesName;
}
+ /**
+ * Gets name key.
+ *
+ * @param gameRuleClass the game rule class
+ * @return the name key
+ */
public static String getNameKey(Class> gameRuleClass) {
return RULE_KEY_PERFiX_ + gameRuleClass.getSimpleName();
}
diff --git a/src/main/java/top/r3944realms/superleadrope/content/gamerule/server/CreateSuperLeashKnotEntityIfAbsent.java b/src/main/java/top/r3944realms/superleadrope/content/gamerule/server/CreateSuperLeashKnotEntityIfAbsent.java
index f983a94..367692d 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/gamerule/server/CreateSuperLeashKnotEntityIfAbsent.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/gamerule/server/CreateSuperLeashKnotEntityIfAbsent.java
@@ -20,13 +20,34 @@ import top.r3944realms.superleadrope.content.gamerule.SLPGamerules;
import static top.r3944realms.superleadrope.content.gamerule.SLPGamerules.GAMERULE_REGISTRY;
+/**
+ * The type Create super leash knot entity if absent.
+ */
public class CreateSuperLeashKnotEntityIfAbsent {
+ /**
+ * The constant DEFAULT_VALUE.
+ */
public static final boolean DEFAULT_VALUE = true;
+ /**
+ * The constant ID.
+ */
public static final String ID = SLPGamerules.getGameruleName(CreateSuperLeashKnotEntityIfAbsent.class);
+ /**
+ * The constant DESCRIPTION_KEY.
+ */
public static final String DESCRIPTION_KEY = SLPGamerules.getDescriptionKey(CreateSuperLeashKnotEntityIfAbsent.class);
+ /**
+ * The constant NAME_KEY.
+ */
public static final String NAME_KEY = SLPGamerules.getNameKey(CreateSuperLeashKnotEntityIfAbsent.class);
+ /**
+ * The constant CATEGORY.
+ */
public static final GameRules.Category CATEGORY = GameRules.Category.PLAYER;
+ /**
+ * Register.
+ */
public static void register() {
GAMERULE_REGISTRY.registerGamerule(ID, CATEGORY, DEFAULT_VALUE);
}
diff --git a/src/main/java/top/r3944realms/superleadrope/content/gamerule/server/TeleportWithLeashedEntities.java b/src/main/java/top/r3944realms/superleadrope/content/gamerule/server/TeleportWithLeashedEntities.java
index 4fa4f39..d599d55 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/gamerule/server/TeleportWithLeashedEntities.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/gamerule/server/TeleportWithLeashedEntities.java
@@ -20,13 +20,34 @@ import top.r3944realms.superleadrope.content.gamerule.SLPGamerules;
import static top.r3944realms.superleadrope.content.gamerule.SLPGamerules.GAMERULE_REGISTRY;
+/**
+ * The type Teleport with leashed entities.
+ */
public class TeleportWithLeashedEntities {
+ /**
+ * The constant DEFAULT_VALUE.
+ */
public static final boolean DEFAULT_VALUE = true;
+ /**
+ * The constant ID.
+ */
public static final String ID = SLPGamerules.getGameruleName(TeleportWithLeashedEntities.class);
+ /**
+ * The constant DESCRIPTION_KEY.
+ */
public static final String DESCRIPTION_KEY = SLPGamerules.getDescriptionKey(TeleportWithLeashedEntities.class);
+ /**
+ * The constant NAME_KEY.
+ */
public static final String NAME_KEY = SLPGamerules.getNameKey(TeleportWithLeashedEntities.class);
+ /**
+ * The constant CATEGORY.
+ */
public static final GameRules.Category CATEGORY = GameRules.Category.PLAYER;
+ /**
+ * Register.
+ */
public static void register() {
GAMERULE_REGISTRY.registerGamerule(ID, CATEGORY, DEFAULT_VALUE);
}
diff --git a/src/main/java/top/r3944realms/superleadrope/content/item/EternalPotatoItem.java b/src/main/java/top/r3944realms/superleadrope/content/item/EternalPotatoItem.java
index dad67f9..69c4322 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/item/EternalPotatoItem.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/item/EternalPotatoItem.java
@@ -42,10 +42,18 @@ import java.util.List;
import java.util.Objects;
import java.util.UUID;
+/**
+ * The type Eternal potato item.
+ */
public class EternalPotatoItem extends Item {
private static final String ITEM_UUID_TAG = "item_uuid";
+ /**
+ * Instantiates a new Eternal potato item.
+ *
+ * @param properties the properties
+ */
public EternalPotatoItem(Properties properties) {
super(properties.rarity(Rarity.EPIC).stacksTo(1));
}
@@ -55,7 +63,11 @@ public class EternalPotatoItem extends Item {
return new EternalPotatoProvider(stack);
}
- /** 获取或生成 ItemStack 的唯一 UUID */
+ /**
+ * 获取或生成 ItemStack 的唯一 UUID @param stack the stack
+ *
+ * @return the or create item uuid
+ */
public static UUID getOrCreateItemUUID(ItemStack stack) {
CompoundTag tag = stack.getOrCreateTag();
if (tag.hasUUID(ITEM_UUID_TAG)) {
@@ -178,10 +190,22 @@ public class EternalPotatoItem extends Item {
return stack.copy();
}
+ /**
+ * Gets desc key.
+ *
+ * @param name the name
+ * @return the desc key
+ */
public static String getDescKey(String name) {
return "item.eternal_potato.tooltip." + name;
}
+ /**
+ * Gets msg key.
+ *
+ * @param name the name
+ * @return the msg key
+ */
public static String getMsgKey(String name) {
return "item.eternal_potato.msg." + name;
}
@@ -213,6 +237,12 @@ public class EternalPotatoItem extends Item {
// }
}
+ /**
+ * Ensure item in inventory.
+ *
+ * @param player the player
+ * @param stack the stack
+ */
public static void ensureItemInInventory(Player player, ItemStack stack) {
if (player.getInventory().add(stack)) return;
diff --git a/src/main/java/top/r3944realms/superleadrope/content/item/SuperLeadRopeItem.java b/src/main/java/top/r3944realms/superleadrope/content/item/SuperLeadRopeItem.java
index 4f604e0..9c1e653 100644
--- a/src/main/java/top/r3944realms/superleadrope/content/item/SuperLeadRopeItem.java
+++ b/src/main/java/top/r3944realms/superleadrope/content/item/SuperLeadRopeItem.java
@@ -42,6 +42,9 @@ import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
+/**
+ * The type Super lead rope item.
+ */
//TODO:
// 1. 可抛掷使用 ***(下个版本实现)
// - 可转移拴绳
@@ -60,6 +63,11 @@ public class SuperLeadRopeItem extends TieredItem implements IForgeItem {
private static final float THROW_SPEED = 1.5F;
+ /**
+ * Instantiates a new Super lead rope item.
+ *
+ * @param pProperties the p properties
+ */
public SuperLeadRopeItem(@NotNull Properties pProperties) {
super(SLPToolTier.STRING,
pProperties
@@ -80,6 +88,12 @@ public class SuperLeadRopeItem extends TieredItem implements IForgeItem {
return InteractionResultHolder.success(lead);
}
+ /**
+ * Can use boolean.
+ *
+ * @param itemStack the item stack
+ * @return the boolean
+ */
public static boolean canUse(@NotNull ItemStack itemStack) {
return itemStack.getDamageValue() < 1000;
}
@@ -99,23 +113,27 @@ public class SuperLeadRopeItem extends TieredItem implements IForgeItem {
}
return InteractionResult.SUCCESS;
}
+
/**
* 右键蹲下绑定到另一实体上
+ *
* @param newHolder 新实体
- * @param player 明确持有玩家
- * @param level 维度世界
- * @return 是否成功
+ * @param player 明确持有玩家
+ * @param level 维度世界
+ * @return 是否成功 boolean
*/
public static boolean bindToEntity(Entity newHolder, Player player, Level level) {
return bindToEntity(newHolder, player, level, player.getOnPos());
}
+
/**
* 右键蹲下绑定到另一实体上
+ *
* @param newHolder 新实体
- * @param player 明确持有玩家
- * @param level 维度世界
- * @param pos 坐标(一般是明确持有玩家的位置)
- * @return 是否成功
+ * @param player 明确持有玩家
+ * @param level 维度世界
+ * @param pos 坐标(一般是明确持有玩家的位置)
+ * @return 是否成功 boolean
*/
public static boolean bindToEntity(Entity newHolder, Player player, Level level, BlockPos pos) {
boolean isSuccess = false;
@@ -146,15 +164,17 @@ public class SuperLeadRopeItem extends TieredItem implements IForgeItem {
/**
* 右键蹲下绑定到支持方块上
- * @param player 明确持有玩家
- * @param level 维度世界
- * @param leashStack 拴绳物品实例
+ *
+ * @param player 明确持有玩家
+ * @param level 维度世界
+ * @param leashStack 拴绳物品实例
* @param shouldBindSelf 是否应该触发拴自己逻辑检查
- * @return 是否成功
+ * @return 是否成功 boolean
*/
public static boolean bindToBlock(Player player, Level level, ItemStack leashStack, boolean shouldBindSelf) {
return bindToBlock(player, level, player.getOnPos(), leashStack, shouldBindSelf);
}
+
/**
* 右键蹲下绑定到支持方块上
*
@@ -163,7 +183,7 @@ public class SuperLeadRopeItem extends TieredItem implements IForgeItem {
* @param pos 坐标(一般是明确持有玩家的位置)
* @param leashStack 拴绳物品实例
* @param shouldBindSelf 是否应该触发拴自己逻辑检查
- * @return 是否成功
+ * @return 是否成功 boolean
*/
public static boolean bindToBlock(Player player, Level level, BlockPos pos, ItemStack leashStack, boolean shouldBindSelf) {
SuperLeashKnotEntity knot = null;
diff --git a/src/main/java/top/r3944realms/superleadrope/core/exception/RidingCycleException.java b/src/main/java/top/r3944realms/superleadrope/core/exception/RidingCycleException.java
index 0290f7e..4cef7af 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/exception/RidingCycleException.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/exception/RidingCycleException.java
@@ -17,10 +17,19 @@ package top.r3944realms.superleadrope.core.exception;
import java.util.UUID;
+/**
+ * The type Riding cycle exception.
+ */
public class RidingCycleException extends IllegalStateException {
private final UUID entityId;
private final UUID vehicleId;
+ /**
+ * Instantiates a new Riding cycle exception.
+ *
+ * @param entityId the entity id
+ * @param vehicleId the vehicle id
+ */
public RidingCycleException(UUID entityId, UUID vehicleId) {
super(String.format("Cyclic riding reference detected. " +
"Entity %s cannot be added as passenger to vehicle %s " +
@@ -30,10 +39,20 @@ public class RidingCycleException extends IllegalStateException {
this.vehicleId = vehicleId;
}
+ /**
+ * Gets entity id.
+ *
+ * @return the entity id
+ */
public UUID getEntityId() {
return entityId;
}
+ /**
+ * Gets vehicle id.
+ *
+ * @return the vehicle id
+ */
public UUID getVehicleId() {
return vehicleId;
}
diff --git a/src/main/java/top/r3944realms/superleadrope/core/hook/LeashRenderHook.java b/src/main/java/top/r3944realms/superleadrope/core/hook/LeashRenderHook.java
index 7511fd1..f77c733 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/hook/LeashRenderHook.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/hook/LeashRenderHook.java
@@ -24,7 +24,17 @@ import top.r3944realms.superleadrope.util.capability.LeashDataInnerAPI;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
+/**
+ * The type Leash render hook.
+ */
public class LeashRenderHook {
+ /**
+ * Should render extra boolean.
+ *
+ * @param mob the mob
+ * @param camera the camera
+ * @return the boolean
+ */
public static boolean shouldRenderExtra(Mob mob, Frustum camera) {
SuperLeadRope.logger.debug("[SuperLeash] Checking entity: {} at position: {}, {}, {}", mob.getName().getString(), mob.getX(), mob.getY(), mob.getZ());
AtomicBoolean flag = new AtomicBoolean(false);
diff --git a/src/main/java/top/r3944realms/superleadrope/core/leash/LeashInteractHandler.java b/src/main/java/top/r3944realms/superleadrope/core/leash/LeashInteractHandler.java
index fa9ab64..89e1bda 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/leash/LeashInteractHandler.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/leash/LeashInteractHandler.java
@@ -37,8 +37,20 @@ import top.r3944realms.superleadrope.util.capability.LeashDataInnerAPI;
import java.util.Optional;
+/**
+ * The type Leash interact handler.
+ */
public class LeashInteractHandler {
- //只有玩家可以互动触发(其它的暂不支持(考虑到0 Mixin)
+ /**
+ * On entity right interact.
+ *
+ * @param level the level
+ * @param hand the hand
+ * @param target the target
+ * @param player the player
+ * @param event the event
+ */
+//只有玩家可以互动触发(其它的暂不支持(考虑到0 Mixin)
public static void onEntityRightInteract(Level level, InteractionHand hand, Entity target , Player player, PlayerInteractEvent.EntityInteract event) {
//WARNING: 主手和副手都会触发一次该事件
@@ -119,6 +131,15 @@ public class LeashInteractHandler {
}
}
+
+ /**
+ * On entity left interact.
+ *
+ * @param level the level
+ * @param target the target
+ * @param player the player
+ * @param event the event
+ */
public static void onEntityLeftInteract(Level level, Entity target , Player player, AttackEntityEvent event) {
boolean flag = LeashDataImpl.isLeashable(target) && player.getItemInHand(InteractionHand.MAIN_HAND).is(SLPItems.SUPER_LEAD_ROPE.get());
if (level.isClientSide) {
diff --git a/src/main/java/top/r3944realms/superleadrope/core/leash/LeashSyncManager.java b/src/main/java/top/r3944realms/superleadrope/core/leash/LeashSyncManager.java
index 01360cd..3997801 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/leash/LeashSyncManager.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/leash/LeashSyncManager.java
@@ -23,28 +23,79 @@ import java.util.Set;
import java.util.WeakHashMap;
import java.util.function.Consumer;
+/**
+ * The type Leash sync manager.
+ */
// 全局LeashData同步管理器
public class LeashSyncManager {
+ /**
+ * The Leash data.
+ */
static final Set LEASH_DATA = Collections.newSetFromMap(new WeakHashMap<>());
+ /**
+ * The Leash states.
+ */
static final Set LEASH_STATES = Collections.newSetFromMap(new WeakHashMap<>());
+
+ /**
+ * The type Data.
+ */
public static class Data {
+ /**
+ * Track.
+ *
+ * @param instance the instance
+ */
public static void track(ILeashData instance) {
LEASH_DATA.add(instance);
}
+
+ /**
+ * Untrack.
+ *
+ * @param instance the instance
+ */
public static void untrack(ILeashData instance) {
LEASH_DATA.remove(instance);
}
+
+ /**
+ * For each.
+ *
+ * @param consumer the consumer
+ */
public static void forEach(Consumer consumer) {
LEASH_DATA.forEach(consumer);
}
}
+
+ /**
+ * The type State.
+ */
public static class State {
+ /**
+ * Track.
+ *
+ * @param instance the instance
+ */
public static void track(ILeashState instance) {
LEASH_STATES.add(instance);
}
+
+ /**
+ * Untrack.
+ *
+ * @param instance the instance
+ */
public static void untrack(ILeashState instance) {
LEASH_STATES.remove(instance);
}
+
+ /**
+ * For each.
+ *
+ * @param consumer the consumer
+ */
public static void forEach(Consumer consumer) {
LEASH_STATES.forEach(consumer);
}
diff --git a/src/main/java/top/r3944realms/superleadrope/core/potato/EternalPotatoFacade.java b/src/main/java/top/r3944realms/superleadrope/core/potato/EternalPotatoFacade.java
index 56d1721..9634578 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/potato/EternalPotatoFacade.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/potato/EternalPotatoFacade.java
@@ -36,31 +36,67 @@ public class EternalPotatoFacade {
private static PotatoSavedData savedData;
// 全局监听器
private static final List listeners = new CopyOnWriteArrayList<>();
+
+ /**
+ * Add listener.
+ *
+ * @param listener the listener
+ */
public static void addListener(IEternalPotatoChangeListener listener) {
listeners.add(listener);
}
+ /**
+ * Remove listener.
+ *
+ * @param listener the listener
+ */
public static void removeListener(IEternalPotatoChangeListener listener) {
listeners.remove(listener);
}
- // 内部方法,用于通知变化
+ /**
+ * Notify change.
+ *
+ * @param uuid the uuid
+ * @param potato the potato
+ */
+// 内部方法,用于通知变化
static void notifyChange(UUID uuid, IEternalPotato potato) {
listeners.forEach(l -> l.onPotatoChanged(uuid, potato));
}
+ /**
+ * Gets manager.
+ *
+ * @return the manager
+ */
public static IEternalPotatoManager getManager() {
return manager;
}
+
+ /**
+ * Gets saved data.
+ *
+ * @return the saved data
+ */
public static PotatoSavedData getSavedData() {
return savedData;
}
+
+ /**
+ * Init saved data.
+ *
+ * @param serverLevel the server level
+ */
public static void initSavedData(ServerLevel serverLevel) {
savedData = PotatoSavedData.create(serverLevel);
}
+
/**
* 初始化(进入世界时调用)
- * @param mode 当前运行模式
+ *
+ * @param mode 当前运行模式
* @param isServer 是否在服务端
*/
public static void init(PotatoMode mode, boolean isServer) {
@@ -73,6 +109,12 @@ public class EternalPotatoFacade {
}
}
+ /**
+ * Gets or create.
+ *
+ * @param uuid the uuid
+ * @return the or create
+ */
public static IEternalPotato getOrCreate(UUID uuid) {
if (manager == null) throw new IllegalStateException("EternalPotatoFacade not initialized!");
IEternalPotato potato = manager.getOrCreate(uuid);
@@ -86,6 +128,11 @@ public class EternalPotatoFacade {
return potato;
}
+ /**
+ * Remove.
+ *
+ * @param uuid the uuid
+ */
public static void remove(UUID uuid) {
if (manager != null) manager.remove(uuid);
@@ -98,10 +145,18 @@ public class EternalPotatoFacade {
}
}
+ /**
+ * Clear.
+ */
public static void clear() {
if (manager != null) manager.clear();
}
+ /**
+ * Is server boolean.
+ *
+ * @return the boolean
+ */
public static boolean isServer() {
return (manager instanceof SyncedEternalPotatoManager synced) && synced.isServer();
}
diff --git a/src/main/java/top/r3944realms/superleadrope/core/potato/IEternalPotatoChangeListener.java b/src/main/java/top/r3944realms/superleadrope/core/potato/IEternalPotatoChangeListener.java
index 2e93285..d187f94 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/potato/IEternalPotatoChangeListener.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/potato/IEternalPotatoChangeListener.java
@@ -19,6 +19,15 @@ import top.r3944realms.superleadrope.content.capability.inter.IEternalPotato;
import java.util.UUID;
+/**
+ * The interface Eternal potato change listener.
+ */
public interface IEternalPotatoChangeListener {
+ /**
+ * On potato changed.
+ *
+ * @param uuid the uuid
+ * @param potato the potato
+ */
void onPotatoChanged(UUID uuid, IEternalPotato potato);
}
diff --git a/src/main/java/top/r3944realms/superleadrope/core/potato/IEternalPotatoManager.java b/src/main/java/top/r3944realms/superleadrope/core/potato/IEternalPotatoManager.java
index a1ef90e..e1a2a08 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/potato/IEternalPotatoManager.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/potato/IEternalPotatoManager.java
@@ -20,12 +20,41 @@ import top.r3944realms.superleadrope.content.capability.inter.IEternalPotato;
import java.util.UUID;
+/**
+ * The interface Eternal potato manager.
+ */
public interface IEternalPotatoManager {
+ /**
+ * Gets or create.
+ *
+ * @param uuid the uuid
+ * @return the or create
+ */
IEternalPotato getOrCreate(UUID uuid);
+ /**
+ * Remove.
+ *
+ * @param uuid the uuid
+ */
void remove(UUID uuid);
+ /**
+ * Clear.
+ */
void clear();
+
+ /**
+ * Save all compound tag.
+ *
+ * @return the compound tag
+ */
CompoundTag saveAll();
+
+ /**
+ * Load all.
+ *
+ * @param tag the tag
+ */
void loadAll(CompoundTag tag);
}
\ No newline at end of file
diff --git a/src/main/java/top/r3944realms/superleadrope/core/potato/PotatoSavedData.java b/src/main/java/top/r3944realms/superleadrope/core/potato/PotatoSavedData.java
index 4263597..bcf0115 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/potato/PotatoSavedData.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/potato/PotatoSavedData.java
@@ -20,7 +20,13 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.saveddata.SavedData;
import org.jetbrains.annotations.NotNull;
+/**
+ * The type Potato saved data.
+ */
public class PotatoSavedData extends SavedData {
+ /**
+ * The constant DATA_NAME.
+ */
public static final String DATA_NAME = "eternal_potato";
@@ -31,6 +37,12 @@ public class PotatoSavedData extends SavedData {
return tag;
}
+ /**
+ * Load potato saved data.
+ *
+ * @param tag the tag
+ * @return the potato saved data
+ */
public static PotatoSavedData load(CompoundTag tag) {
IEternalPotatoManager manager = EternalPotatoFacade.getManager();
PotatoSavedData data = new PotatoSavedData();
@@ -40,7 +52,13 @@ public class PotatoSavedData extends SavedData {
return data;
}
- // 工厂方法(Forge 推荐写法)
+ /**
+ * Create potato saved data.
+ *
+ * @param level the level
+ * @return the potato saved data
+ */
+// 工厂方法(Forge 推荐写法)
public static PotatoSavedData create(ServerLevel level) {
return level.getDataStorage().computeIfAbsent(
PotatoSavedData::load,
diff --git a/src/main/java/top/r3944realms/superleadrope/core/potato/SyncedEternalPotatoManager.java b/src/main/java/top/r3944realms/superleadrope/core/potato/SyncedEternalPotatoManager.java
index b4fbbcf..aab105e 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/potato/SyncedEternalPotatoManager.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/potato/SyncedEternalPotatoManager.java
@@ -34,6 +34,12 @@ import java.util.concurrent.ConcurrentHashMap;
class SyncedEternalPotatoManager implements IEternalPotatoManager {
private final Map GLOBAL_DATA = new ConcurrentHashMap<>();
private final boolean isServer;
+
+ /**
+ * Instantiates a new Synced eternal potato manager.
+ *
+ * @param isServer the is server
+ */
public SyncedEternalPotatoManager(boolean isServer) {
this.isServer = isServer;
}
@@ -83,6 +89,11 @@ class SyncedEternalPotatoManager implements IEternalPotatoManager {
}
}
+ /**
+ * Is server boolean.
+ *
+ * @return the boolean
+ */
public boolean isServer() {
return isServer;
}
diff --git a/src/main/java/top/r3944realms/superleadrope/core/punishment/DailyPunishmentHandler.java b/src/main/java/top/r3944realms/superleadrope/core/punishment/DailyPunishmentHandler.java
index 531ffee..c069c84 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/punishment/DailyPunishmentHandler.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/punishment/DailyPunishmentHandler.java
@@ -30,6 +30,9 @@ import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
+/**
+ * The type Daily punishment handler.
+ */
public class DailyPunishmentHandler {
private static long lastProcessedDay = -1;
@@ -41,6 +44,9 @@ public class DailyPunishmentHandler {
private static final Map countdownMap = new ConcurrentHashMap<>();
+ /**
+ * On server tick.
+ */
public static void onServerTick() {
var server = ServerLifecycleHooks.getCurrentServer();
diff --git a/src/main/java/top/r3944realms/superleadrope/core/punishment/IObligationCompletion.java b/src/main/java/top/r3944realms/superleadrope/core/punishment/IObligationCompletion.java
index 8659825..6bb1a42 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/punishment/IObligationCompletion.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/punishment/IObligationCompletion.java
@@ -42,8 +42,11 @@ public interface IObligationCompletion {
* @param stack 操作的物品
*/
void onCompleted(ServerPlayer player, ItemStack stack);
+
/**
* 获取注册 ID
+ *
+ * @return the id
*/
default String getId() {
for (Map.Entry entry : SLPObligationCompletionRegistry.getAll().entrySet()) {
@@ -51,15 +54,28 @@ public interface IObligationCompletion {
}
return "none";
}
- // --- 网络序列化 ---
+
+ /**
+ * To network.
+ *
+ * @param buf the buf
+ */
+// --- 网络序列化 ---
default void toNetwork(FriendlyByteBuf buf) {
buf.writeUtf(this.getId());
}
+ /**
+ * From network obligation completion.
+ *
+ * @param buf the buf
+ * @return the obligation completion
+ */
static IObligationCompletion fromNetwork(FriendlyByteBuf buf) {
String id = buf.readUtf();
return SLPObligationCompletionRegistry.byId(id); // 如果没找到,返回 NONE
}
+
/**
* 一个便捷的静态空实现(默认永不完成)
*/
diff --git a/src/main/java/top/r3944realms/superleadrope/core/punishment/PunishmentDefinition.java b/src/main/java/top/r3944realms/superleadrope/core/punishment/PunishmentDefinition.java
index 8f9a953..5e40747 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/punishment/PunishmentDefinition.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/punishment/PunishmentDefinition.java
@@ -33,33 +33,67 @@ import org.jetbrains.annotations.Nullable;
public record PunishmentDefinition(PunishmentDefinition.Type type, float strength,
boolean affectOthers) {
+ /**
+ * The constant DEFAULT.
+ */
public static final PunishmentDefinition DEFAULT = new PunishmentDefinition(Type.LIGHTNING, 0, false);
+ /**
+ * The enum Type.
+ */
public enum Type {
+ /**
+ * Lightning type.
+ */
LIGHTNING, // 雷劈
+ /**
+ * Explosion type.
+ */
EXPLOSION, // 爆炸
+ /**
+ * Effect type.
+ */
EFFECT // 给予负面效果
}
- /** 序列化到网络 */
+
+ /**
+ * 序列化到网络 @param buf the buf
+ */
public void toNetwork(FriendlyByteBuf buf) {
buf.writeEnum(this.type);
buf.writeFloat(this.strength);
buf.writeBoolean(this.affectOthers);
}
- /** 从网络反序列化 */
+ /**
+ * 从网络反序列化 @param buf the buf
+ *
+ * @return the punishment definition
+ */
public static PunishmentDefinition fromNetwork(FriendlyByteBuf buf) {
Type type = buf.readEnum(Type.class);
float strength = buf.readFloat();
boolean affectOthers = buf.readBoolean();
return new PunishmentDefinition(type, strength, affectOthers);
}
+
/**
* 执行惩罚
+ *
+ * @param target the target
+ * @param cause the cause
*/
public void execute(ServerPlayer target, DamageSource cause) {
execute(target, cause, null);
}
+
+ /**
+ * Execute.
+ *
+ * @param target the target
+ * @param cause the cause
+ * @param actionMessage the action message
+ */
public void execute(ServerPlayer target, DamageSource cause,@Nullable Component actionMessage) {
ServerLevel level = (ServerLevel) target.level();
switch (type) {
diff --git a/src/main/java/top/r3944realms/superleadrope/core/register/SLPEntityTypes.java b/src/main/java/top/r3944realms/superleadrope/core/register/SLPEntityTypes.java
index 0542a8b..4cf3479 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/register/SLPEntityTypes.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/register/SLPEntityTypes.java
@@ -24,9 +24,18 @@ import net.minecraftforge.registries.RegistryObject;
import top.r3944realms.superleadrope.SuperLeadRope;
import top.r3944realms.superleadrope.content.entity.SuperLeashKnotEntity;
+/**
+ * The type Slp entity types.
+ */
public class SLPEntityTypes {
+ /**
+ * The Entity types.
+ */
public static DeferredRegister> ENTITY_TYPES =
DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, SuperLeadRope.MOD_ID);
+ /**
+ * The Super lead knot.
+ */
public static RegistryObject> SUPER_LEAD_KNOT = ENTITY_TYPES.register(
"super_lead_knot",
() -> EntityType.Builder.of(SuperLeashKnotEntity::new, MobCategory.MISC)
@@ -36,9 +45,22 @@ public class SLPEntityTypes {
.updateInterval(Integer.MAX_VALUE)
.build("super_lead_knot")
);
+
+ /**
+ * Gets entity name key.
+ *
+ * @param entityName the entity name
+ * @return the entity name key
+ */
public static String getEntityNameKey(String entityName) {
return "entity." + SuperLeadRope.MOD_ID + "." + entityName;
}
+
+ /**
+ * Register.
+ *
+ * @param bus the bus
+ */
public static void register(IEventBus bus) {
ENTITY_TYPES.register(bus);
}
diff --git a/src/main/java/top/r3944realms/superleadrope/core/register/SLPGameruleRegistry.java b/src/main/java/top/r3944realms/superleadrope/core/register/SLPGameruleRegistry.java
index d4858b1..47c35c4 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/register/SLPGameruleRegistry.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/register/SLPGameruleRegistry.java
@@ -26,14 +26,44 @@ import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;
+/**
+ * The enum Slp gamerule registry.
+ */
public enum SLPGameruleRegistry {
+ /**
+ * Instance slp gamerule registry.
+ */
INSTANCE;
+ /**
+ * The constant gamerules.
+ */
public static final Map> gamerules = new HashMap<>();;
+ /**
+ * The constant gameruleDataTypes.
+ */
public static final Map gameruleDataTypes = new HashMap<>();
+
+ /**
+ * The enum Rule data type.
+ */
public enum RuleDataType {
+ /**
+ * Boolean rule data type.
+ */
BOOLEAN,
+ /**
+ * Integer rule data type.
+ */
INTEGER,
}
+
+ /**
+ * Gets gamerule bool value.
+ *
+ * @param level the level
+ * @param gameruleName the gamerule name
+ * @return the gamerule bool value
+ */
@SuppressWarnings("unchecked")
public static boolean getGameruleBoolValue(Level level, String gameruleName) {
@@ -45,6 +75,14 @@ public enum SLPGameruleRegistry {
}
return level.getGameRules().getBoolean((GameRules.Key) gamerules.get(gameruleName));
}
+
+ /**
+ * Gets gamerule int value.
+ *
+ * @param level the level
+ * @param gameruleName the gamerule name
+ * @return the gamerule int value
+ */
@SuppressWarnings("unchecked")
public static Integer getGameruleIntValue(Level level, String gameruleName) {
if (level.isClientSide && SLPGamerules.gameruleIntegerValuesClient.containsKey(gameruleName)) {
@@ -56,20 +94,57 @@ public enum SLPGameruleRegistry {
return level.getGameRules().getInt((GameRules.Key)gamerules.get(gameruleName));
}
+ /**
+ * Register gamerule.
+ *
+ * @param gameruleName the gamerule name
+ * @param category the category
+ * @param pDefault the p default
+ */
public void registerGamerule(String gameruleName, GameRules.Category category, boolean pDefault) {
registerGamerule(gameruleName, category, pDefault, (s,i)->{});//最后一个仅占位无用
}
+
+ /**
+ * Register gamerule.
+ *
+ * @param gameruleName the gamerule name
+ * @param category the category
+ * @param pDefault the p default
+ * @param pChangeListener the p change listener
+ */
public void registerGamerule(String gameruleName, GameRules.Category category, boolean pDefault, BiConsumer pChangeListener) {
gamerules.put(gameruleName, GameRules.register(gameruleName, category, GameRules.BooleanValue.create(pDefault, pChangeListener)));
gameruleDataTypes.put(gameruleName, RuleDataType.BOOLEAN);
}
+
+ /**
+ * Register gamerule.
+ *
+ * @param gameruleName the gamerule name
+ * @param category the category
+ * @param pDefault the p default
+ */
public void registerGamerule(String gameruleName, GameRules.Category category, int pDefault) {
registerGamerule(gameruleName, category, pDefault, (s, i)->{});//最后一个仅占位无用
}
+
+ /**
+ * Register gamerule.
+ *
+ * @param gameruleName the gamerule name
+ * @param category the category
+ * @param pDefault the p default
+ * @param pChangeListener the p change listener
+ */
public void registerGamerule(String gameruleName, GameRules.Category category, int pDefault, BiConsumer pChangeListener) {
gamerules.put(gameruleName, GameRules.register(gameruleName, category, GameRules.IntegerValue.create(pDefault, pChangeListener)));
gameruleDataTypes.put(gameruleName, RuleDataType.INTEGER);
}
+
+ /**
+ * Register.
+ */
public static void register() {
TeleportWithLeashedEntities.register();
CreateSuperLeashKnotEntityIfAbsent.register();
diff --git a/src/main/java/top/r3944realms/superleadrope/core/register/SLPItems.java b/src/main/java/top/r3944realms/superleadrope/core/register/SLPItems.java
index c3590f4..be3aa51 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/register/SLPItems.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/register/SLPItems.java
@@ -24,12 +24,24 @@ import top.r3944realms.superleadrope.SuperLeadRope;
import top.r3944realms.superleadrope.content.item.EternalPotatoItem;
import top.r3944realms.superleadrope.content.item.SuperLeadRopeItem;
+/**
+ * The type Slp items.
+ */
public class SLPItems {
+ /**
+ * The constant ITEMS.
+ */
public static final DeferredRegister
- ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, SuperLeadRope.MOD_ID);
+ /**
+ * The constant SUPER_LEAD_ROPE.
+ */
public static final RegistryObject
- SUPER_LEAD_ROPE = ITEMS.register(
"super_lead_rope",
() -> new SuperLeadRopeItem(new Item.Properties())
);
+ /**
+ * The constant ETERNAL_POTATO.
+ */
public static final RegistryObject
- ETERNAL_POTATO =
ITEMS.register("eternal_potato",
() -> new EternalPotatoItem(
@@ -37,6 +49,12 @@ public class SLPItems {
.stacksTo(1) // 只能有一颗
.fireResistant() // 防火
));
+
+ /**
+ * Register.
+ *
+ * @param bus the bus
+ */
public static void register(IEventBus bus) {
ITEMS.register(bus);
}
diff --git a/src/main/java/top/r3944realms/superleadrope/core/register/SLPObligationCompletionRegistry.java b/src/main/java/top/r3944realms/superleadrope/core/register/SLPObligationCompletionRegistry.java
index 8ab1881..0a33f49 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/register/SLPObligationCompletionRegistry.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/register/SLPObligationCompletionRegistry.java
@@ -31,7 +31,8 @@ public class SLPObligationCompletionRegistry {
/**
* 注册一个 IObligationCompletion 实例
- * @param id 唯一 ID
+ *
+ * @param id 唯一 ID
* @param completion 实例
*/
public static void register(String id, IObligationCompletion completion) {
@@ -42,8 +43,9 @@ public class SLPObligationCompletionRegistry {
/**
* 根据 ID 获取 IObligationCompletion 实例
+ *
* @param id ID
- * @return 实例,如果未注册则返回 NONE
+ * @return 实例 ,如果未注册则返回 NONE
*/
public static IObligationCompletion byId(String id) {
return REGISTRY.getOrDefault(id, IObligationCompletion.NONE);
@@ -51,6 +53,8 @@ public class SLPObligationCompletionRegistry {
/**
* 获取只读注册表(用于调试或枚举)
+ *
+ * @return the all
*/
public static Map getAll() {
return Collections.unmodifiableMap(REGISTRY);
diff --git a/src/main/java/top/r3944realms/superleadrope/core/register/SLPSoundEvents.java b/src/main/java/top/r3944realms/superleadrope/core/register/SLPSoundEvents.java
index 6a5f1c9..899c5ce 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/register/SLPSoundEvents.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/register/SLPSoundEvents.java
@@ -23,21 +23,58 @@ import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import top.r3944realms.superleadrope.SuperLeadRope;
+/**
+ * The type Slp sound events.
+ */
public class SLPSoundEvents {
+ /**
+ * The constant SOUND_EVENTS.
+ */
public static final DeferredRegister SOUND_EVENTS = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, SuperLeadRope.MOD_ID);
+ /**
+ * The constant RL_LEAD_UNTIED.
+ */
public static final ResourceLocation RL_LEAD_UNTIED = new ResourceLocation(SuperLeadRope.MOD_ID,"item/superlead/lead_untied");
+ /**
+ * The constant RL_LEAD_TIED.
+ */
public static final ResourceLocation RL_LEAD_TIED = new ResourceLocation(SuperLeadRope.MOD_ID,"item/superlead/lead_tied");
+ /**
+ * The constant RL_LEAD_BREAK.
+ */
public static final ResourceLocation RL_LEAD_BREAK = new ResourceLocation(SuperLeadRope.MOD_ID,"item/superlead/lead_break");
+ /**
+ * The constant LEAD_UNTIED.
+ */
public static final RegistryObject LEAD_UNTIED = registerSound("lead_untied");
+ /**
+ * The constant LEAD_TIED.
+ */
public static final RegistryObject LEAD_TIED = registerSound("lead_tied");
+ /**
+ * The constant LEAD_BREAK.
+ */
public static final RegistryObject LEAD_BREAK = registerSound("lead_break");
private static RegistryObject registerSound(String name) {
ResourceLocation location = new ResourceLocation(SuperLeadRope.MOD_ID, name);
return SOUND_EVENTS.register(name, () -> SoundEvent.createVariableRangeEvent(location));
}
+
+ /**
+ * Register.
+ *
+ * @param bus the bus
+ */
public static void register(IEventBus bus) {
SOUND_EVENTS.register(bus);
}
+
+ /**
+ * Gets sub title translate key.
+ *
+ * @param name the name
+ * @return the sub title translate key
+ */
public static String getSubTitleTranslateKey(String name) {
return "sound." + SuperLeadRope.MOD_ID + ".subtitle." + name;
}
diff --git a/src/main/java/top/r3944realms/superleadrope/core/util/ImmutablePair.java b/src/main/java/top/r3944realms/superleadrope/core/util/ImmutablePair.java
index 21d153a..ebb3e0c 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/util/ImmutablePair.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/util/ImmutablePair.java
@@ -17,8 +17,23 @@ package top.r3944realms.superleadrope.core.util;
import java.util.Objects;
+/**
+ * The type Immutable pair.
+ *
+ * @param the type parameter
+ * @param
the type parameter
+ */
public record ImmutablePair(F first, S second) {
+ /**
+ * Of immutable pair.
+ *
+ * @param the type parameter
+ * @param the type parameter
+ * @param first the first
+ * @param second the second
+ * @return the immutable pair
+ */
public static ImmutablePair of(F first, S second) {
return new ImmutablePair<>(first, second);
}
diff --git a/src/main/java/top/r3944realms/superleadrope/core/util/PotatoMode.java b/src/main/java/top/r3944realms/superleadrope/core/util/PotatoMode.java
index b3fcedd..75c2d50 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/util/PotatoMode.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/util/PotatoMode.java
@@ -15,6 +15,9 @@
package top.r3944realms.superleadrope.core.util;
+/**
+ * The enum Potato mode.
+ */
public enum PotatoMode {
/**
* 单人 or 局域网主机
@@ -28,6 +31,12 @@ public enum PotatoMode {
* 远程连接的客户端
*/
REMOTE_CLIENT;
+
+ /**
+ * Is synced boolean.
+ *
+ * @return the boolean
+ */
public boolean isSynced() {
// Synced 模式:DEDICATED 服务端 + REMOTE_CLIENT 客户端
return this == DEDICATED || this == REMOTE_CLIENT;
diff --git a/src/main/java/top/r3944realms/superleadrope/core/util/PotatoModeHelper.java b/src/main/java/top/r3944realms/superleadrope/core/util/PotatoModeHelper.java
index c749fb4..976d095 100644
--- a/src/main/java/top/r3944realms/superleadrope/core/util/PotatoModeHelper.java
+++ b/src/main/java/top/r3944realms/superleadrope/core/util/PotatoModeHelper.java
@@ -20,8 +20,16 @@ import net.minecraft.server.MinecraftServer;
import net.minecraftforge.fml.loading.FMLEnvironment;
import net.minecraftforge.server.ServerLifecycleHooks;
+/**
+ * The type Potato mode helper.
+ */
public class PotatoModeHelper {
+ /**
+ * Gets current mode.
+ *
+ * @return the current mode
+ */
public static PotatoMode getCurrentMode() {
if (FMLEnvironment.dist.isClient()) {
Minecraft mc = Minecraft.getInstance();
diff --git a/src/main/java/top/r3944realms/superleadrope/datagen/SLPDataGenEvent.java b/src/main/java/top/r3944realms/superleadrope/datagen/SLPDataGenEvent.java
index a66efd9..b92376e 100644
--- a/src/main/java/top/r3944realms/superleadrope/datagen/SLPDataGenEvent.java
+++ b/src/main/java/top/r3944realms/superleadrope/datagen/SLPDataGenEvent.java
@@ -29,9 +29,21 @@ import top.r3944realms.superleadrope.util.lang.LanguageEnum;
import java.util.concurrent.CompletableFuture;
+/**
+ * The type Slp data gen event.
+ */
@Mod.EventBusSubscriber(modid = SuperLeadRope.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class SLPDataGenEvent {
+ /**
+ * The Logger.
+ */
static Logger logger = LoggerFactory.getLogger(SLPDataGenEvent.class);
+
+ /**
+ * Gather data.
+ *
+ * @param event the event
+ */
@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
logger.info("GatherDataEvent thread: {}", Thread.currentThread().getName());
diff --git a/src/main/java/top/r3944realms/superleadrope/datagen/data/SLPAdvancementKey.java b/src/main/java/top/r3944realms/superleadrope/datagen/data/SLPAdvancementKey.java
index 66139b6..7e037f3 100644
--- a/src/main/java/top/r3944realms/superleadrope/datagen/data/SLPAdvancementKey.java
+++ b/src/main/java/top/r3944realms/superleadrope/datagen/data/SLPAdvancementKey.java
@@ -18,6 +18,9 @@ import top.r3944realms.superleadrope.SuperLeadRope;
import javax.annotation.Nullable;
+/**
+ * The enum Slp advancement key.
+ */
public enum SLPAdvancementKey {
;
private final String Name;
@@ -28,16 +31,38 @@ public enum SLPAdvancementKey {
this.Parent = parent;
}
+ /**
+ * Gets parent.
+ *
+ * @return the parent
+ */
public @Nullable SLPAdvancementKey getParent() {
return Parent;
}
+
+ /**
+ * Gets name key.
+ *
+ * @return the name key
+ */
public String getNameKey() {
return "advancement." + SuperLeadRope.MOD_ID + "." + Name;
}
+ /**
+ * Gets desc key.
+ *
+ * @return the desc key
+ */
public String getDescKey() {
return this.getNameKey() + ".desc";
}
+
+ /**
+ * Gets name with name space.
+ *
+ * @return the name with name space
+ */
public String getNameWithNameSpace() {
return SuperLeadRope.MOD_ID + ":" + this.Name;
}
diff --git a/src/main/java/top/r3944realms/superleadrope/datagen/data/SLPLangKeyValue.java b/src/main/java/top/r3944realms/superleadrope/datagen/data/SLPLangKeyValue.java
index c4b6d37..6ed08eb 100644
--- a/src/main/java/top/r3944realms/superleadrope/datagen/data/SLPLangKeyValue.java
+++ b/src/main/java/top/r3944realms/superleadrope/datagen/data/SLPLangKeyValue.java
@@ -33,17 +33,29 @@ import javax.annotation.Nullable;
import java.util.function.Supplier;
+/**
+ * The enum Slp lang key value.
+ */
public enum SLPLangKeyValue {
+ /**
+ * The Item super lead rope.
+ */
ITEM_SUPER_LEAD_ROPE(
SLPItems.SUPER_LEAD_ROPE, ModPartEnum.ITEM,
"Super Lead Rope", "超级拴绳", "超級拴繩","神駒羈縻索"
),
+ /**
+ * The Item eternal potato.
+ */
ITEM_ETERNAL_POTATO(
SLPItems.ETERNAL_POTATO, ModPartEnum.ITEM,
"Eternal Potato", "永恒土豆", "永恆馬鈴薯", "不滅薯", true
),
+ /**
+ * The Ep tooltip title.
+ */
EP_TOOLTIP_TITLE(
EternalPotatoItem.getDescKey("title"), ModPartEnum.DESCRIPTION,
"§6Mythical Item §7- §6Eternal Potato",
@@ -52,6 +64,9 @@ public enum SLPLangKeyValue {
"§6永恒土豆 §7- §6传奇之物"
),
+ /**
+ * The Ep desc tooltip.
+ */
EP_DESC_TOOLTIP(
EternalPotatoItem.getDescKey("desc"), ModPartEnum.DESCRIPTION,
"§7Symbol of server-wide contract, cannot be discarded",
@@ -60,6 +75,9 @@ public enum SLPLangKeyValue {
"§7象征全服契约,绝不可弃"
),
+ /**
+ * The Ep bind owner.
+ */
EP_BIND_OWNER(
EternalPotatoItem.getDescKey("bind_owner"), ModPartEnum.DESCRIPTION,
"§bBound Owner: §f%s",
@@ -68,6 +86,9 @@ public enum SLPLangKeyValue {
"§b绑定主人: §f%s"
),
+ /**
+ * Ep unbound slp lang key value.
+ */
EP_UNBOUND(EternalPotatoItem.getDescKey("unbound"), ModPartEnum.DESCRIPTION,
"§cUnbound",
"§c未绑定主人",
@@ -75,6 +96,9 @@ public enum SLPLangKeyValue {
"§c尚未绑定主人"
),
+ /**
+ * The Ep obligation tooltip.
+ */
EP_OBLIGATION_TOOLTIP(
EternalPotatoItem.getDescKey("obligation"), ModPartEnum.DESCRIPTION,
"§7Daily obligations remaining: §a%d §c(+%d§c overdue)",
@@ -83,6 +107,9 @@ public enum SLPLangKeyValue {
"§7今日责务尚余: §a%d §c(+%d §c逾期未尽)"
),
+ /**
+ * The Ep punish tooltip.
+ */
EP_PUNISH_TOOLTIP(
EternalPotatoItem.getDescKey("punish"), ModPartEnum.DESCRIPTION,
"§cOverdue punishments: §4%d §7(will be applied), grace exceeded: §4%d",
@@ -91,6 +118,9 @@ public enum SLPLangKeyValue {
"§c逾期责务尚未完成: §4%d §7(將受懲罰),超出寬限數: §4%d"
),
+ /**
+ * The Ep obligation info.
+ */
EP_OBLIGATION_INFO(
EternalPotatoItem.getMsgKey("obligation_info"), ModPartEnum.MESSAGE,
"§e[Eternal Potato] §fThis is the server-wide shared person, remaining obligations today: §a%d§f.",
@@ -99,6 +129,9 @@ public enum SLPLangKeyValue {
"§e[永恒土豆] §f此为全服共享之人,今日责务尚余:§a%d§f次。"
),
+ /**
+ * The Ep potato heal.
+ */
EP_POTATO_HEAL(
EternalPotatoItem.getMsgKey("potato_heal"), ModPartEnum.MESSAGE,
"§aThe power of the Eternal Potato comforts you, it won't disappear.",
@@ -107,6 +140,9 @@ public enum SLPLangKeyValue {
"§a永恒土豆之力慰心,永不消逝。"
),
+ /**
+ * The Ep cannot drop.
+ */
EP_CANNOT_DROP(
EternalPotatoItem.getMsgKey("cannot_drop"), ModPartEnum.MESSAGE,
"§cThe Eternal Potato cannot be dropped! +%d punishments.",
@@ -115,6 +151,9 @@ public enum SLPLangKeyValue {
"§c永恒土豆不可丟棄,懲罰數增加%d!"
),
+ /**
+ * The Ep bind msg.
+ */
EP_BIND_MSG(
EternalPotatoItem.getMsgKey("bind_msg"), ModPartEnum.MESSAGE,
"§6Bound to you as the server-wide shared person.",
@@ -124,7 +163,9 @@ public enum SLPLangKeyValue {
),
-
+ /**
+ * The Ep obligation done.
+ */
EP_OBLIGATION_DONE(
EternalPotatoItem.getMsgKey("obligation_done"), ModPartEnum.MESSAGE,
"§eObligation completed, remaining: §a%d§e",
@@ -133,6 +174,9 @@ public enum SLPLangKeyValue {
"§e责务完成,尚余 §a%d §e次。"
),
+ /**
+ * The Ep obligation full.
+ */
EP_OBLIGATION_FULL(
EternalPotatoItem.getMsgKey("obligation_full"), ModPartEnum.MESSAGE,
"§aAll obligations completed today!",
@@ -141,6 +185,9 @@ public enum SLPLangKeyValue {
"§a今日责务尽矣!"
),
+ /**
+ * The Ep punish msg.
+ */
EP_PUNISH_MSG(
EternalPotatoItem.getMsgKey("punish_msg"), ModPartEnum.MESSAGE,
"§cYesterday obligations incomplete, punished!",
@@ -149,6 +196,9 @@ public enum SLPLangKeyValue {
"§c昨日之责未尽,受罚矣!"
),
+ /**
+ * The Ep obligation countdown.
+ */
EP_OBLIGATION_COUNTDOWN(EternalPotatoItem.getMsgKey("obligation_countdown"), ModPartEnum.MESSAGE,
"Punish Countdown: §a%d §fseconds remaining",
"惩罚倒计时: §a%d §f秒",
@@ -156,6 +206,9 @@ public enum SLPLangKeyValue {
"受罚倒数:§a%d §f瞬"
),
+ /**
+ * The Ep pickup not owner.
+ */
EP_PICKUP_NOT_OWNER(
EternalPotatoItem.getMsgKey("pickup_not_owner"), ModPartEnum.MESSAGE,
"§cYou are not the rightful owner and cannot pick this up!",
@@ -164,6 +217,9 @@ public enum SLPLangKeyValue {
"§c非汝所主,勿取!"
),
+ /**
+ * The Ep punish not owner.
+ */
EP_PUNISH_NOT_OWNER(
EternalPotatoItem.getMsgKey("punish_not_owner"), ModPartEnum.MESSAGE,
"§cYou are not the rightful owner, punished by lightning!",
@@ -171,6 +227,9 @@ public enum SLPLangKeyValue {
"§c非綁定主人使用,受到閃電懲罰!",
"§c非汝所主,雷霆降身!"
),
+ /**
+ * The Ep punish not owner death msg.
+ */
EP_PUNISH_NOT_OWNER_DEATH_MSG(
"death.attack.eternal_potato_not_owner", ModPartEnum.MESSAGE,
"§c%1$s was not the rightful owner, struck by lightning!",
@@ -178,6 +237,9 @@ public enum SLPLangKeyValue {
"§c%1$s 因使用非自己綁定物品,受到閃電懲罰!",
"§c%1$s 非汝所主,雷霆降身!"
),
+ /**
+ * The Ep punish not compete death msg.
+ */
EP_PUNISH_NOT_COMPETE_DEATH_MSG(
"death.attack.eternal_potato_not_complete", ModPartEnum.MESSAGE,
"§c%1$s was not the rightful owner, struck by lightning!",
@@ -185,25 +247,40 @@ public enum SLPLangKeyValue {
"§c%1$s 因使用非自己綁定物品,受到閃電懲罰!",
"§c%1$s 非汝所主,雷霆降身!"
),
+ /**
+ * The Sound subtitle super lead break.
+ */
SOUND_SUBTITLE_SUPER_LEAD_BREAK(
SLPSoundEvents.getSubTitleTranslateKey("lead_break"), ModPartEnum.SOUND,
"Lead Break", "拴绳断裂", "拴繩斷裂", "索絕"
),
+ /**
+ * The Sound subtitle super lead tied.
+ */
SOUND_SUBTITLE_SUPER_LEAD_TIED(
SLPSoundEvents.getSubTitleTranslateKey("lead_tied"), ModPartEnum.SOUND,
"Lead Tied", "拴绳系上", "拴繩係上", "繫索"
),
+ /**
+ * The Sound subtitle super lead untied.
+ */
SOUND_SUBTITLE_SUPER_LEAD_UNTIED(
SLPSoundEvents.getSubTitleTranslateKey("lead_untied"), ModPartEnum.SOUND,
"Lead Untie", "拴绳解开", "拴繩解開", "解索"
),
+ /**
+ * The Entity super lead knot.
+ */
ENTITY_SUPER_LEAD_KNOT(
SLPEntityTypes.getEntityNameKey("super_lead_knot"), ModPartEnum.ENTITY,
"Super Lead Knot", "超级拴绳结", "超級拴繩結", "神駒羈縻索結"
),
+ /**
+ * The Teleport with leashed entities name.
+ */
TELEPORT_WITH_LEASHED_ENTITIES_NAME(
TeleportWithLeashedEntities.NAME_KEY, ModPartEnum.GAME_RULE,
"Teleport leashed player with holder",
@@ -211,6 +288,9 @@ public enum SLPLangKeyValue {
"被拴实体随持有者傳送",
"繫畜隨持者傳送"
),
+ /**
+ * The Create super leash knot entity if absent name.
+ */
CREATE_SUPER_LEASH_KNOT_ENTITY_IF_ABSENT_NAME(
CreateSuperLeashKnotEntityIfAbsent.NAME_KEY, ModPartEnum.NAME,
"Create Leash Fence Knot Entity if absent",
@@ -218,6 +298,9 @@ public enum SLPLangKeyValue {
"如果缺失則創建超級拴繩結",
"若阙则创超级繫绳结"
),
+ /**
+ * The Create super leash knot entity if absent description.
+ */
CREATE_SUPER_LEASH_KNOT_ENTITY_IF_ABSENT_DESCRIPTION(
CreateSuperLeashKnotEntityIfAbsent.DESCRIPTION_KEY, ModPartEnum.DESCRIPTION,
"Create LeashKnot Entity if it's absent on fence or other supported positions",
@@ -225,6 +308,9 @@ public enum SLPLangKeyValue {
"如果在柵欄等支持處缺失超級拴繩結,則創建它",
"若栅等支处阙超级繫绳结,则创之"
),
+ /**
+ * The Teleport with leashed description.
+ */
TELEPORT_WITH_LEASHED_DESCRIPTION(
TeleportWithLeashedEntities.DESCRIPTION_KEY, ModPartEnum.DESCRIPTION,
"Holder will teleport with their leashed players ",
@@ -232,6 +318,9 @@ public enum SLPLangKeyValue {
"將被拴实体將隨持有者一起傳送",
"傳送時繫畜隨持者同傳"
),
+ /**
+ * The Message motion adder successful.
+ */
MESSAGE_MOTION_ADDER_SUCCESSFUL(
MotionCommand.MOTION_ADDER_SUCCESSFUL, ModPartEnum.COMMAND,
"§bAdd Successfully.§a%s§7:§f[§eVec§7:§a(§f%.2f§7,§f%.2f§7,§f%.2f§7)§f]§r",
@@ -239,6 +328,9 @@ public enum SLPLangKeyValue {
"§b添加成功.§a%s§7:§f[§e加速§7:(§a%.2f§7,§a%.2f§7,§a%.2f§7)§f]§r",
"§b增益既成.§a%s§7:§f[§e速勢§7:(§a%.2f§7,§a%.2f§7,§a%.2f§7)§f]§r"
),
+ /**
+ * The Message motion setter successful.
+ */
MESSAGE_MOTION_SETTER_SUCCESSFUL(
MotionCommand.MOTION_SETTER_SUCCESSFUL, ModPartEnum.COMMAND,
"§bSet Successfully.§a%s§7:§f[§eVec§7:§a(§f%.2f§7,§f%.2f§7,§f%.2f§7)§f]§r",
@@ -246,6 +338,9 @@ public enum SLPLangKeyValue {
"§b設置成功.§a%s§7:§f[§e加速§7:(§a%.2f§7,§a%.2f§7,§a%.2f§7)§f]§r",
"§b定值既成.§a%s§7:§f[§e速勢§7:(§a%.2f§7,§a%.2f§7,§a%.2f§7)§f]§r"
),
+ /**
+ * The Message motion multiply successful.
+ */
MESSAGE_MOTION_MULTIPLY_SUCCESSFUL(
MotionCommand.MOTION_MULTIPLY_SUCCESSFUL, ModPartEnum.COMMAND,
"§bMultiply Successfully.§a%s§7:§f[§eVec§7:§a(§f%.2f§7,§f%.2f§7,§f%.2f§7)§f]§r",
@@ -253,6 +348,9 @@ public enum SLPLangKeyValue {
"§b倍乘成功.§a%s§7:§f[§e加速§7:(§a%.2f§7,§a%.2f§7,§a%.2f§7)§f]§r",
"§b倍乘既成.§a%s§7:§f[§e速勢§7:(§a%.2f§7,§a%.2f§7,§a%.2f§7)§f]§r"
),
+ /**
+ * The Message leashdata get title.
+ */
MESSAGE_LEASHDATA_GET_TITLE(
LeashDataCommand.TITLE, ModPartEnum.COMMAND,
"=== Leash Data for %s ===",
@@ -260,6 +358,9 @@ public enum SLPLangKeyValue {
"=== %s 的拴繩數據 ===",
"=== %s 之繫繩數據 ==="
),
+ /**
+ * The Message leashdata get total.
+ */
MESSAGE_LEASHDATA_GET_TOTAL(
LeashDataCommand.TOTAL, ModPartEnum.COMMAND,
"Total leashes: %d",
@@ -267,6 +368,9 @@ public enum SLPLangKeyValue {
"總拴繩數: %d",
"繫繩總數: %d"
),
+ /**
+ * Message leashdata get block slp lang key value.
+ */
MESSAGE_LEASHDATA_GET_BLOCK(
LeashDataCommand.BLOCK, ModPartEnum.COMMAND,
"§7Block: §e%s",
@@ -274,6 +378,9 @@ public enum SLPLangKeyValue {
"§7方塊: §e%s",
"§7磚石: §e%s"
),
+ /**
+ * Message leashdata get uuid slp lang key value.
+ */
MESSAGE_LEASHDATA_GET_UUID(
LeashDataCommand.UUID, ModPartEnum.COMMAND,
"§7UUID: §b%s",
@@ -281,6 +388,9 @@ public enum SLPLangKeyValue {
"§7UUID: §b%s",
"§7UUID: §b%s"
),
+ /**
+ * Message leashdata get max slp lang key value.
+ */
MESSAGE_LEASHDATA_GET_MAX(
LeashDataCommand.MAX, ModPartEnum.COMMAND,
"§7Max: §a%.1f",
@@ -288,6 +398,9 @@ public enum SLPLangKeyValue {
"§7最大距離: §a%.1f",
"§7極距: §a%.1f"
),
+ /**
+ * Message leashdata get elastic slp lang key value.
+ */
MESSAGE_LEASHDATA_GET_ELASTIC(
LeashDataCommand.ELASTIC, ModPartEnum.COMMAND,
"§7Elastic: §6%.1f",
@@ -295,6 +408,9 @@ public enum SLPLangKeyValue {
"§7彈性距離: §6%.1f",
"§7彈距: §6%.1f"
),
+ /**
+ * Message leashdata get keep slp lang key value.
+ */
MESSAGE_LEASHDATA_GET_KEEP(
LeashDataCommand.KEEP, ModPartEnum.COMMAND,
"§7Keep: §c%d§7/§c%d",
@@ -302,6 +418,9 @@ public enum SLPLangKeyValue {
"§7保持: §c%d§7/§c%d",
"§7持時: §c%d§7/§c%d"
),
+ /**
+ * Message leashdata get reserved slp lang key value.
+ */
MESSAGE_LEASHDATA_GET_RESERVED(
LeashDataCommand.RESERVED, ModPartEnum.COMMAND,
"§7Reserved: §d%s",
@@ -309,6 +428,9 @@ public enum SLPLangKeyValue {
"§7保留字段: §d%s",
"§7備註: §d%s"
),
+ /**
+ * The Message leashdata add success.
+ */
MESSAGE_LEASHDATA_ADD_SUCCESS(
"command.leashdata.addApplyEntity.success", ModPartEnum.COMMAND,
"§bAdded leash successfully. §a%s §7→ §e%s",
@@ -316,6 +438,9 @@ public enum SLPLangKeyValue {
"§b添加拴繩成功. §a%s §7→ §e%s",
"§b繫繩既添. §a%s §7→ §e%s"
),
+ /**
+ * The Message leashdata remove success.
+ */
MESSAGE_LEASHDATA_REMOVE_SUCCESS(
"command.leashdata.removeApplyEntity.success", ModPartEnum.COMMAND,
"§bRemoved leash successfully. §a%s §7- §e%s",
@@ -323,6 +448,9 @@ public enum SLPLangKeyValue {
"§b移除拴繩成功. §a%s §7- §e%s",
"§b繫繩既除. §a%s §7- §e%s"
),
+ /**
+ * The Message leashdata transfer success.
+ */
MESSAGE_LEASHDATA_TRANSFER_SUCCESS(
"command.leashdata.transfer.success", ModPartEnum.COMMAND,
"§bTransferred leash successfully. §a%s §7→ §e%s §7→ §6%s",
@@ -330,6 +458,9 @@ public enum SLPLangKeyValue {
"§b轉移拴繩成功. §a%s §7→ §e%s §7→ §6%s",
"§b繫繩既移. §a%s §7→ §e%s §7→ §6%s"
),
+ /**
+ * The Message leashdata set success.
+ */
MESSAGE_LEASHDATA_SET_SUCCESS(
"command.leashdata.setApplyEntity.success", ModPartEnum.COMMAND,
"§bSet leash property successfully. §a%s §7: §e%s §7= §6%.1f",
@@ -385,6 +516,14 @@ public enum SLPLangKeyValue {
SLPLangKeyValue(@NotNull String ResourceKey, ModPartEnum MPE, String US_EN, String SIM_CN, String TRA_CN) {
this(ResourceKey, MPE, US_EN, SIM_CN, TRA_CN, null, false);
}
+
+ /**
+ * Gets lan.
+ *
+ * @param lan the lan
+ * @param key the key
+ * @return the lan
+ */
public static String getLan(LanguageEnum lan, SLPLangKeyValue key) {
if (lan == null || lan == LanguageEnum.English) return getEnglish(key);
else {
@@ -413,10 +552,23 @@ public enum SLPLangKeyValue {
private static String getTraditionalChinese(SLPLangKeyValue key) {
return key.TRA_CN;
}
+
+ /**
+ * Gets literary chinese.
+ *
+ * @param key the key
+ * @return the literary chinese
+ */
@Nullable
public static String getLiteraryChinese(SLPLangKeyValue key) {
return key.LZH;
}
+
+ /**
+ * Gets key.
+ *
+ * @return the key
+ */
public String getKey() {
if(key == null){
switch (MPE) {//Don't need to use "break;"[Java feature];
@@ -429,19 +581,43 @@ public enum SLPLangKeyValue {
}
return key;
}
+
+ /**
+ * Gets item.
+ *
+ * @return the item
+ */
@SuppressWarnings("null")
public Item getItem() {
assert supplier != null;
return (Item)supplier.get();
}
+
+ /**
+ * Gets block.
+ *
+ * @return the block
+ */
@SuppressWarnings("null")
public Block getBlock() {
assert supplier != null;
return (Block)supplier.get();
}
+
+ /**
+ * Is default item boolean.
+ *
+ * @return the boolean
+ */
public boolean isDefaultItem(){
return MPE == ModPartEnum.ITEM && Default;
}
+
+ /**
+ * Is default block boolean.
+ *
+ * @return the boolean
+ */
public boolean isDefaultBlock() {
return MPE == ModPartEnum.BLOCK && Default;
}
diff --git a/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPBlockTagProvider.java b/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPBlockTagProvider.java
index 0f1c16b..0e1dc40 100644
--- a/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPBlockTagProvider.java
+++ b/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPBlockTagProvider.java
@@ -25,7 +25,17 @@ import top.r3944realms.superleadrope.SuperLeadRope;
import java.util.concurrent.CompletableFuture;
+/**
+ * The type Slp block tag provider.
+ */
public class SLPBlockTagProvider extends BlockTagsProvider {
+ /**
+ * Instantiates a new Slp block tag provider.
+ *
+ * @param output the output
+ * @param lookupProvider the lookup provider
+ * @param existingFileHelper the existing file helper
+ */
public SLPBlockTagProvider(
PackOutput output,
CompletableFuture lookupProvider,
diff --git a/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPItemModelProvider.java b/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPItemModelProvider.java
index 35902bd..69e828f 100644
--- a/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPItemModelProvider.java
+++ b/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPItemModelProvider.java
@@ -30,11 +30,26 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
+/**
+ * The type Slp item model provider.
+ */
public class SLPItemModelProvider extends ItemModelProvider {
private static List- objectList;
+ /**
+ * The constant GENERATED.
+ */
public static final String GENERATED = "item/generated";
+ /**
+ * The constant HANDHELD.
+ */
public static final String HANDHELD = "item/handheld";
+ /**
+ * Instantiates a new Slp item model provider.
+ *
+ * @param output the output
+ * @param existingFileHelper the existing file helper
+ */
public SLPItemModelProvider(PackOutput output, ExistingFileHelper existingFileHelper) {
super(output, SuperLeadRope.MOD_ID, existingFileHelper);
objectList = new ArrayList<>();
@@ -59,12 +74,29 @@ public class SLPItemModelProvider extends ItemModelProvider {
objectList.forEach(this::basicItem);
}
+ /**
+ * Item generate model.
+ *
+ * @param item the item
+ * @param location the location
+ */
public void itemGenerateModel(Item item, ResourceLocation location){
withExistingParent(itemName(item), GENERATED).texture("layer0", location);
}
+
+ /**
+ * Item hand held model.
+ *
+ * @param item the item
+ * @param location the location
+ */
public void itemHandHeldModel(Item item, ResourceLocation location){
withExistingParent(itemName(item), HANDHELD).texture("layer0", location);
}
+
+ /**
+ * Super lead rope model.
+ */
public void superLeadRopeModel() {
// 生成主模型,支持根据 predicate 切换模型
ItemModelBuilder builder = getBuilder(SuperLeadRope.MOD_ID + ":super_lead_rope");
@@ -83,10 +115,22 @@ public class SLPItemModelProvider extends ItemModelProvider {
.texture("layer0", resourceItem("broken_super_lead_rope"));
}
+ /**
+ * Item name string.
+ *
+ * @param item the item
+ * @return the string
+ */
public String itemName(Item item){
return Objects.requireNonNull(ForgeRegistries.ITEMS.getKey(item)).getPath();
}
+ /**
+ * Resource item resource location.
+ *
+ * @param path the path
+ * @return the resource location
+ */
public ResourceLocation resourceItem(String path){
return modLoc("item/" + path);
}
diff --git a/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPItemRecipeProvider.java b/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPItemRecipeProvider.java
index fa766ab..0446016 100644
--- a/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPItemRecipeProvider.java
+++ b/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPItemRecipeProvider.java
@@ -26,7 +26,15 @@ import top.r3944realms.superleadrope.core.register.SLPItems;
import java.util.function.Consumer;
+/**
+ * The type Slp item recipe provider.
+ */
public class SLPItemRecipeProvider extends RecipeProvider {
+ /**
+ * Instantiates a new Slp item recipe provider.
+ *
+ * @param output the output
+ */
public SLPItemRecipeProvider(PackOutput output) {
super(output);
}
diff --git a/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPItemTagProvider.java b/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPItemTagProvider.java
index 16e4eb6..cb61a34 100644
--- a/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPItemTagProvider.java
+++ b/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPItemTagProvider.java
@@ -27,7 +27,17 @@ import top.r3944realms.superleadrope.content.SLPTags;
import java.util.concurrent.CompletableFuture;
+/**
+ * The type Slp item tag provider.
+ */
public class SLPItemTagProvider extends ItemTagsProvider {
+ /**
+ * Instantiates a new Slp item tag provider.
+ *
+ * @param packOutput the pack output
+ * @param holderProvider the holder provider
+ * @param existingFileHelper the existing file helper
+ */
public SLPItemTagProvider(
PackOutput packOutput,
CompletableFuture holderProvider,
diff --git a/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPLanguageProvider.java b/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPLanguageProvider.java
index ee9310f..abe209b 100644
--- a/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPLanguageProvider.java
+++ b/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPLanguageProvider.java
@@ -29,10 +29,20 @@ import java.util.Map;
import static top.r3944realms.superleadrope.datagen.data.SLPLangKeyValue.getLan;
+/**
+ * The type Slp language provider.
+ */
public class SLPLanguageProvider extends LanguageProvider {
private final LanguageEnum Language;
private final Map LanKeyMap;
private static final List objects = new ArrayList<>();
+
+ /**
+ * Instantiates a new Slp language provider.
+ *
+ * @param output the output
+ * @param Lan the lan
+ */
public SLPLanguageProvider(PackOutput output, LanguageEnum Lan) {
super(output, SuperLeadRope.MOD_ID, Lan.local);
this.Language = Lan;
diff --git a/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPSoundDefinitionsProvider.java b/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPSoundDefinitionsProvider.java
index 8213154..1548702 100644
--- a/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPSoundDefinitionsProvider.java
+++ b/src/main/java/top/r3944realms/superleadrope/datagen/provider/SLPSoundDefinitionsProvider.java
@@ -22,10 +22,27 @@ import net.minecraftforge.common.data.SoundDefinitionsProvider;
import top.r3944realms.superleadrope.SuperLeadRope;
import top.r3944realms.superleadrope.core.register.SLPSoundEvents;
+/**
+ * The type Slp sound definitions provider.
+ */
public class SLPSoundDefinitionsProvider extends SoundDefinitionsProvider {
+ /**
+ * Instantiates a new Slp sound definitions provider.
+ *
+ * @param output the output
+ * @param helper the helper
+ */
public SLPSoundDefinitionsProvider(PackOutput output, ExistingFileHelper helper) {
super(output, SuperLeadRope.MOD_ID, helper);
}
+
+ /**
+ * Gets sound definition.
+ *
+ * @param subTitle the sub title
+ * @param sounds the sounds
+ * @return the sound definition
+ */
public SoundDefinition getSoundDefinition(String subTitle, SoundDefinition.Sound... sounds) {
return SoundDefinition.definition().subtitle(subTitle).with(sounds);
}
diff --git a/src/main/java/top/r3944realms/superleadrope/network/NetworkHandler.java b/src/main/java/top/r3944realms/superleadrope/network/NetworkHandler.java
index 8f1ba9d..6e2bd71 100644
--- a/src/main/java/top/r3944realms/superleadrope/network/NetworkHandler.java
+++ b/src/main/java/top/r3944realms/superleadrope/network/NetworkHandler.java
@@ -25,14 +25,24 @@ import top.r3944realms.superleadrope.SuperLeadRope;
import top.r3944realms.superleadrope.network.toClient.*;
+/**
+ * The type Network handler.
+ */
public class NetworkHandler {
private static int cid = 0;
+ /**
+ * The constant INSTANCE.
+ */
public static final SimpleChannel INSTANCE = NetworkRegistry.newSimpleChannel(
new ResourceLocation(SuperLeadRope.MOD_ID, "main"),
() -> SuperLeadRope.ModInfo.VERSION,
SuperLeadRope.ModInfo.VERSION::equals,
SuperLeadRope.ModInfo.VERSION::equals
);
+
+ /**
+ * Register.
+ */
public static void register() {
INSTANCE.messageBuilder(LeashDataSyncPacket.class, cid++, NetworkDirection.PLAY_TO_CLIENT)
.decoder(LeashDataSyncPacket::decode)
@@ -60,9 +70,27 @@ public class NetworkHandler {
.consumerNetworkThread(LeashStateSyncPacket::handle)
.add();
}
+
+ /**
+ * Send to player.
+ *
+ * @param the type parameter
+ * @param message the message
+ * @param player the player
+ */
public static void sendToPlayer(MSG message, ServerPlayer player){
INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), message);
}
+
+ /**
+ * Send to player.
+ *
+ * @param the type parameter
+ * @param the type parameter
+ * @param message the message
+ * @param entity the entity
+ * @param packetDistributor the packet distributor
+ */
public static void sendToPlayer(MSG message, T entity, PacketDistributor packetDistributor){
INSTANCE.send(packetDistributor.with(() -> entity), message);
}
diff --git a/src/main/java/top/r3944realms/superleadrope/network/toClient/EternalPotatoSyncCapPacket.java b/src/main/java/top/r3944realms/superleadrope/network/toClient/EternalPotatoSyncCapPacket.java
index 69fb0c1..c31ccfc 100644
--- a/src/main/java/top/r3944realms/superleadrope/network/toClient/EternalPotatoSyncCapPacket.java
+++ b/src/main/java/top/r3944realms/superleadrope/network/toClient/EternalPotatoSyncCapPacket.java
@@ -10,6 +10,9 @@ import top.r3944realms.superleadrope.core.punishment.PunishmentDefinition;
import java.util.UUID;
import java.util.function.Supplier;
+/**
+ * The type Eternal potato sync cap packet.
+ */
public record EternalPotatoSyncCapPacket(
UUID itemUUID,
UUID ownerUUID,
@@ -23,7 +26,13 @@ public record EternalPotatoSyncCapPacket(
IObligationCompletion completionRule
) {
- // 编码
+ /**
+ * Encode.
+ *
+ * @param msg the msg
+ * @param buf the buf
+ */
+// 编码
public static void encode(EternalPotatoSyncCapPacket msg, FriendlyByteBuf buf) {
buf.writeUUID(msg.itemUUID);
@@ -48,7 +57,13 @@ public record EternalPotatoSyncCapPacket(
}
}
- // 解码
+ /**
+ * Decode eternal potato sync cap packet.
+ *
+ * @param buf the buf
+ * @return the eternal potato sync cap packet
+ */
+// 解码
public static EternalPotatoSyncCapPacket decode(FriendlyByteBuf buf) {
UUID itemUUID = buf.readUUID();
UUID ownerUUID = buf.readBoolean() ? buf.readUUID() : null;
@@ -73,7 +88,13 @@ public record EternalPotatoSyncCapPacket(
lastReset, lastPunishDate, punishment, completionRule);
}
- // 处理
+ /**
+ * Handle.
+ *
+ * @param msg the msg
+ * @param ctx the ctx
+ */
+// 处理
public static void handle(EternalPotatoSyncCapPacket msg, Supplier ctx) {
ctx.get().enqueueWork(() -> {
// 获取全局能力实例
diff --git a/src/main/java/top/r3944realms/superleadrope/network/toClient/LeashDataSyncPacket.java b/src/main/java/top/r3944realms/superleadrope/network/toClient/LeashDataSyncPacket.java
index 5eff45f..03f5614 100644
--- a/src/main/java/top/r3944realms/superleadrope/network/toClient/LeashDataSyncPacket.java
+++ b/src/main/java/top/r3944realms/superleadrope/network/toClient/LeashDataSyncPacket.java
@@ -25,17 +25,38 @@ import top.r3944realms.superleadrope.util.capability.LeashDataInnerAPI;
import java.util.function.Supplier;
+/**
+ * The type Leash data sync packet.
+ */
public record LeashDataSyncPacket(int entityId, CompoundTag leashData) {
+ /**
+ * Encode.
+ *
+ * @param msg the msg
+ * @param buffer the buffer
+ */
public static void encode(LeashDataSyncPacket msg, FriendlyByteBuf buffer) {
buffer.writeInt(msg.entityId);
buffer.writeNbt(msg.leashData);
}
+ /**
+ * Decode leash data sync packet.
+ *
+ * @param buffer the buffer
+ * @return the leash data sync packet
+ */
public static LeashDataSyncPacket decode(FriendlyByteBuf buffer) {
return new LeashDataSyncPacket(buffer.readInt(), buffer.readNbt());
}
+ /**
+ * Handle.
+ *
+ * @param msg the msg
+ * @param ctx the ctx
+ */
public static void handle(LeashDataSyncPacket msg, Supplier ctx) {
ctx.get().enqueueWork(() -> {
ClientLevel level = Minecraft.getInstance().level;
diff --git a/src/main/java/top/r3944realms/superleadrope/network/toClient/LeashStateSyncPacket.java b/src/main/java/top/r3944realms/superleadrope/network/toClient/LeashStateSyncPacket.java
index 322ae9b..a1c9a90 100644
--- a/src/main/java/top/r3944realms/superleadrope/network/toClient/LeashStateSyncPacket.java
+++ b/src/main/java/top/r3944realms/superleadrope/network/toClient/LeashStateSyncPacket.java
@@ -25,16 +25,37 @@ import top.r3944realms.superleadrope.api.SLPCapability;
import java.util.function.Supplier;
+/**
+ * The type Leash state sync packet.
+ */
public record LeashStateSyncPacket(int entityId, CompoundTag leashState) {
+ /**
+ * Encode.
+ *
+ * @param msg the msg
+ * @param buffer the buffer
+ */
public static void encode(LeashStateSyncPacket msg, FriendlyByteBuf buffer) {
buffer.writeInt(msg.entityId);
buffer.writeNbt(msg.leashState);
}
+ /**
+ * Decode leash state sync packet.
+ *
+ * @param buffer the buffer
+ * @return the leash state sync packet
+ */
public static LeashStateSyncPacket decode(FriendlyByteBuf buffer) {
return new LeashStateSyncPacket(buffer.readInt(), buffer.readNbt());
}
+ /**
+ * Handle.
+ *
+ * @param msg the msg
+ * @param ctx the ctx
+ */
public static void handle(LeashStateSyncPacket msg, Supplier ctx) {
ctx.get().enqueueWork(() -> {
ClientLevel level = Minecraft.getInstance().level;
diff --git a/src/main/java/top/r3944realms/superleadrope/network/toClient/PacketEternalPotatoRemovePacket.java b/src/main/java/top/r3944realms/superleadrope/network/toClient/PacketEternalPotatoRemovePacket.java
index 9e29774..b7d5670 100644
--- a/src/main/java/top/r3944realms/superleadrope/network/toClient/PacketEternalPotatoRemovePacket.java
+++ b/src/main/java/top/r3944realms/superleadrope/network/toClient/PacketEternalPotatoRemovePacket.java
@@ -22,15 +22,36 @@ import top.r3944realms.superleadrope.core.potato.EternalPotatoFacade;
import java.util.UUID;
import java.util.function.Supplier;
+/**
+ * The type Packet eternal potato remove packet.
+ */
public record PacketEternalPotatoRemovePacket(UUID itemUUID) {
+ /**
+ * Encode.
+ *
+ * @param msg the msg
+ * @param buf the buf
+ */
public static void encode(PacketEternalPotatoRemovePacket msg, FriendlyByteBuf buf) {
buf.writeUUID(msg.itemUUID());
}
+ /**
+ * Decode packet eternal potato remove packet.
+ *
+ * @param buf the buf
+ * @return the packet eternal potato remove packet
+ */
public static PacketEternalPotatoRemovePacket decode(FriendlyByteBuf buf) {
return new PacketEternalPotatoRemovePacket(buf.readUUID());
}
+ /**
+ * Handle.
+ *
+ * @param msg the msg
+ * @param ctx the ctx
+ */
public static void handle(PacketEternalPotatoRemovePacket msg, Supplier ctx) {
ctx.get().enqueueWork(() -> {
// 客户端收到移除请求
diff --git a/src/main/java/top/r3944realms/superleadrope/network/toClient/UpdatePlayerMovementPacket.java b/src/main/java/top/r3944realms/superleadrope/network/toClient/UpdatePlayerMovementPacket.java
index 83d17fb..41afc14 100644
--- a/src/main/java/top/r3944realms/superleadrope/network/toClient/UpdatePlayerMovementPacket.java
+++ b/src/main/java/top/r3944realms/superleadrope/network/toClient/UpdatePlayerMovementPacket.java
@@ -23,17 +23,39 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
+/**
+ * The type Update player movement packet.
+ */
public record UpdatePlayerMovementPacket(Operation operation, double x, double y, double z) {
+ /**
+ * Encode.
+ *
+ * @param packet the packet
+ * @param buffer the buffer
+ */
public static void encode(UpdatePlayerMovementPacket packet, FriendlyByteBuf buffer) {
buffer.writeEnum(packet.operation());
buffer.writeDouble(packet.x());
buffer.writeDouble(packet.y());
buffer.writeDouble(packet.z());
}
+
+ /**
+ * Instantiates a new Update player movement packet.
+ *
+ * @param operation the operation
+ * @param vec the vec
+ */
public UpdatePlayerMovementPacket(Operation operation, Vec3 vec) {
this(operation, vec.x, vec.y, vec.z);
}
+ /**
+ * Decode update player movement packet.
+ *
+ * @param buffer the buffer
+ * @return the update player movement packet
+ */
public static UpdatePlayerMovementPacket decode(FriendlyByteBuf buffer) {
return new UpdatePlayerMovementPacket(
buffer.readEnum(Operation.class),
@@ -43,6 +65,12 @@ public record UpdatePlayerMovementPacket(Operation operation, double x, double y
);
}
+ /**
+ * Handle.
+ *
+ * @param packet the packet
+ * @param ctx the ctx
+ */
public static void handle(UpdatePlayerMovementPacket packet, Supplier ctx) {
NetworkEvent.Context context = ctx.get();
context.enqueueWork(() -> {
@@ -57,9 +85,22 @@ public record UpdatePlayerMovementPacket(Operation operation, double x, double y
);
context.setPacketHandled(true);
}
+
+ /**
+ * The enum Operation.
+ */
public enum Operation {
+ /**
+ * Set operation.
+ */
SET,
+ /**
+ * Add operation.
+ */
ADD,
+ /**
+ * Multiply operation.
+ */
MULTIPLY
}
}
diff --git a/src/main/java/top/r3944realms/superleadrope/util/capability/LeashDataInnerAPI.java b/src/main/java/top/r3944realms/superleadrope/util/capability/LeashDataInnerAPI.java
index c23241d..99ca692 100644
--- a/src/main/java/top/r3944realms/superleadrope/util/capability/LeashDataInnerAPI.java
+++ b/src/main/java/top/r3944realms/superleadrope/util/capability/LeashDataInnerAPI.java
@@ -32,75 +32,192 @@ import java.util.*;
@SuppressWarnings("unused")
@ApiStatus.Internal
public final class LeashDataInnerAPI {
- // ==================== 基础能力获取 ====================
+ /**
+ * Gets leash data.
+ *
+ * @param entity the entity
+ * @return the leash data
+ */
+// ==================== 基础能力获取 ====================
public static @NotNull Optional getLeashData(@NotNull Entity entity) {
Objects.requireNonNull(entity, "Entity cannot be null");
return entity.getCapability(SLPCapability.LEASH_DATA_CAP).resolve();
}
// ==================== 拴绳数据管理 API ====================
+ /**
+ * The type Leash operations.
+ */
public static final class LeashOperations {
private LeashOperations() {}
- // ---------------------- 添加拴绳 ----------------------
+ /**
+ * Attach boolean.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @return the boolean
+ */
+// ---------------------- 添加拴绳 ----------------------
public static boolean attach(Entity entity, Entity holder) {
return getLeashData(entity).map(data -> data.addLeash(holder)).orElse(false);
}
+ /**
+ * Attach boolean.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @param reserved the reserved
+ * @return the boolean
+ */
public static boolean attach(Entity entity, Entity holder, String reserved) {
return getLeashData(entity).map(data -> data.addLeash(holder, reserved)).orElse(false);
}
+ /**
+ * Attach boolean.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @param maxDistance the max distance
+ * @return the boolean
+ */
public static boolean attach(Entity entity, Entity holder, double maxDistance) {
return getLeashData(entity).map(data -> data.addLeash(holder, maxDistance)).orElse(false);
}
+ /**
+ * Attach boolean.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @param maxDistance the max distance
+ * @param elasticDistance 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);
}
+ /**
+ * Attach boolean.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @param maxDistance the max distance
+ * @param reserved the reserved
+ * @return the boolean
+ */
public static boolean attach(Entity entity, Entity holder, double maxDistance, String reserved) {
return getLeashData(entity).map(data -> data.addLeash(holder, maxDistance, reserved)).orElse(false);
}
+ /**
+ * Attach boolean.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @param maxDistance the max distance
+ * @param elasticDistance 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);
}
+ /**
+ * Attach with info.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @param info the info
+ */
public static void attachWithInfo(Entity entity, Entity holder, LeashInfo info) {
getLeashData(entity).ifPresent(data -> data.addLeash(holder, info));
}
- // ---------------------- 延迟拴绳 ----------------------
+ /**
+ * Attach delayed.
+ *
+ * @param entity the entity
+ * @param holderPlayer the holder player
+ */
+// ---------------------- 延迟拴绳 ----------------------
public static void attachDelayed(Entity entity, Player holderPlayer) {
getLeashData(entity).ifPresent(data -> data.addDelayedLeash(holderPlayer));
}
+ /**
+ * Remove delayed.
+ *
+ * @param entity the entity
+ * @param onceHolderPlayerUUID the once holder player uuid
+ */
public static void removeDelayed(Entity entity, UUID onceHolderPlayerUUID) {
getLeashData(entity).ifPresent(data -> data.removeDelayedLeash(onceHolderPlayerUUID));
}
- // ---------------------- 移除拴绳 ----------------------
+ /**
+ * Detach boolean.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @return the boolean
+ */
+// ---------------------- 移除拴绳 ----------------------
public static boolean detach(Entity entity, Entity holder) {
return getLeashData(entity).map(data -> data.removeLeash(holder)).orElse(false);
}
+ /**
+ * Detach boolean.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ * @return the boolean
+ */
public static boolean detach(Entity entity, UUID holderUUID) {
return getLeashData(entity).map(data -> data.removeLeash(holderUUID)).orElse(false);
}
+ /**
+ * Detach boolean.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ * @return the boolean
+ */
public static boolean detach(Entity entity, BlockPos knotPos) {
return getLeashData(entity).map(data -> data.removeLeash(knotPos)).orElse(false);
}
+ /**
+ * Detach all.
+ *
+ * @param entity the entity
+ */
public static void detachAll(Entity entity) {
getLeashData(entity).ifPresent(ILeashData::removeAllLeashes);
}
+ /**
+ * Detach all holders.
+ *
+ * @param entity the entity
+ */
public static void detachAllHolders(Entity entity) {
getLeashData(entity).ifPresent(ILeashData::removeAllHolderLeashes);
}
+ /**
+ * Detach all knots.
+ *
+ * @param entity the entity
+ */
public static void detachAllKnots(Entity entity) {
getLeashData(entity).ifPresent(ILeashData::removeAllKnotLeashes);
}
@@ -108,79 +225,244 @@ public final class LeashDataInnerAPI {
// ==================== 拴绳属性修改 API ====================
+ /**
+ * The type Property operations.
+ */
public static final class PropertyOperations {
private PropertyOperations() {}
- // ---------------------- 设置最大距离 ----------------------
+ /**
+ * 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, 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
+ * @param maxKeepTicks the max keep ticks
+ * @return the max distance
+ */
public static boolean setMaxDistance(Entity entity, Entity holder, double distance, int maxKeepTicks) {
return getLeashData(entity).map(data -> data.setMaxDistance(holder, distance, maxKeepTicks)).orElse(false);
}
+ /**
+ * Sets max distance.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @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);
}
+ /**
+ * Sets max distance.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ * @param distance the distance
+ * @return the max distance
+ */
public static boolean setMaxDistance(Entity entity, UUID holderUUID, double distance) {
return getLeashData(entity).map(data -> data.setMaxDistance(holderUUID, distance)).orElse(false);
}
+ /**
+ * Sets max distance.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @return the max distance
+ */
public static boolean setMaxDistance(Entity entity, UUID holderUUID, double distance, int maxKeepTicks) {
return getLeashData(entity).map(data -> data.setMaxDistance(holderUUID, distance, maxKeepTicks)).orElse(false);
}
+ /**
+ * Sets max distance.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @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);
}
+ /**
+ * Sets max distance.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ * @param distance the distance
+ * @return the max distance
+ */
public static boolean setMaxDistance(Entity entity, BlockPos knotPos, double distance) {
return getLeashData(entity).map(data -> data.setMaxDistance(knotPos, distance)).orElse(false);
}
+ /**
+ * Sets max distance.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @return the max distance
+ */
public static boolean setMaxDistance(Entity entity, BlockPos knotPos, double distance, int maxKeepTicks) {
return getLeashData(entity).map(data -> data.setMaxDistance(knotPos, distance, maxKeepTicks)).orElse(false);
}
+ /**
+ * Sets max distance.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @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);
}
- // ---------------------- 设置弹性距离 ----------------------
+ /**
+ * Sets elastic distance.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @param distance the distance
+ * @return the elastic distance
+ */
+// ---------------------- 设置弹性距离 ----------------------
public static boolean setElasticDistance(Entity entity, Entity holder, double distance) {
return getLeashData(entity).map(data -> data.setElasticDistanceScale(holder, distance)).orElse(false);
}
+ /**
+ * Sets elastic distance.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @return the elastic distance
+ */
public static boolean setElasticDistance(Entity entity, Entity holder, double distance, int maxKeepTicks) {
return getLeashData(entity).map(data -> data.setElasticDistanceScale(holder, distance, maxKeepTicks)).orElse(false);
}
+ /**
+ * Sets elastic distance.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @param reserved the reserved
+ * @return the elastic distance
+ */
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);
}
+ /**
+ * Sets elastic distance.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ * @param distance the distance
+ * @return the elastic distance
+ */
public static boolean setElasticDistance(Entity entity, UUID holderUUID, double distance) {
return getLeashData(entity).map(data -> data.setElasticDistanceScale(holderUUID, distance)).orElse(false);
}
+ /**
+ * Sets elastic distance.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @return the elastic distance
+ */
public static boolean setElasticDistance(Entity entity, UUID holderUUID, double distance, int maxKeepTicks) {
return getLeashData(entity).map(data -> data.setElasticDistanceScale(holderUUID, distance, maxKeepTicks)).orElse(false);
}
+ /**
+ * Sets elastic distance.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @param reserved the reserved
+ * @return the elastic distance
+ */
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);
}
+ /**
+ * Sets elastic distance.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ * @param distance the distance
+ * @return the elastic distance
+ */
public static boolean setElasticDistance(Entity entity, BlockPos knotPos, double distance) {
return getLeashData(entity).map(data -> data.setElasticDistanceScale(knotPos, distance)).orElse(false);
}
+ /**
+ * Sets elastic distance.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @return the elastic distance
+ */
public static boolean setElasticDistance(Entity entity, BlockPos knotPos, double distance, int maxKeepTicks) {
return getLeashData(entity).map(data -> data.setElasticDistanceScale(knotPos, distance, maxKeepTicks)).orElse(false);
}
+ /**
+ * Sets elastic distance.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ * @param distance the distance
+ * @param maxKeepTicks the max keep ticks
+ * @param reserved the reserved
+ * @return the elastic distance
+ */
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);
}
@@ -188,9 +470,17 @@ public final class LeashDataInnerAPI {
// ==================== 物理应用 API ====================
+ /**
+ * The type Physics operations.
+ */
public static final class PhysicsOperations {
private PhysicsOperations() {}
+ /**
+ * Apply forces.
+ *
+ * @param entity the entity
+ */
public static void applyForces(Entity entity) {
getLeashData(entity).ifPresent(ILeashData::applyLeashForces);
}
@@ -198,29 +488,83 @@ public final class LeashDataInnerAPI {
// ==================== 拴绳转移 API ====================
+ /**
+ * The type Transfer operations.
+ */
public static final class TransferOperations {
private TransferOperations() {}
+ /**
+ * Transfer boolean.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @param newHolder the new holder
+ * @return the boolean
+ */
public static boolean transfer(Entity entity, Entity holder, Entity newHolder) {
return getLeashData(entity).map(data -> data.transferLeash(holder, newHolder)).orElse(false);
}
+ /**
+ * Transfer boolean.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @param newHolder the new holder
+ * @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);
}
+ /**
+ * Transfer boolean.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ * @param newHolder the new holder
+ * @return the boolean
+ */
public static boolean transfer(Entity entity, UUID holderUUID, Entity newHolder) {
return getLeashData(entity).map(data -> data.transferLeash(holderUUID, newHolder)).orElse(false);
}
+ /**
+ * Transfer boolean.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ * @param newHolder the new holder
+ * @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);
}
+ /**
+ * Transfer boolean.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ * @param newHolder the new holder
+ * @return the boolean
+ */
public static boolean transfer(Entity entity, BlockPos knotPos, Entity newHolder) {
return getLeashData(entity).map(data -> data.transferLeash(knotPos, newHolder)).orElse(false);
}
+ /**
+ * Transfer boolean.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ * @param newHolder the new holder
+ * @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);
}
@@ -228,57 +572,146 @@ public final class LeashDataInnerAPI {
// ==================== 查询操作 API ====================
+ /**
+ * The type Query operations.
+ */
public static final class QueryOperations {
private QueryOperations() {}
+ /**
+ * Has leash boolean.
+ *
+ * @param entity the entity
+ * @return the boolean
+ */
public static boolean hasLeash(Entity entity) {
return getLeashData(entity).map(ILeashData::hasLeash).orElse(false);
}
+ /**
+ * Has knot leash boolean.
+ *
+ * @param entity the entity
+ * @return the boolean
+ */
public static boolean hasKnotLeash(Entity entity) {
return getLeashData(entity).map(ILeashData::hasKnotLeash).orElse(false);
}
+ /**
+ * Has holder leash boolean.
+ *
+ * @param entity the entity
+ * @return the boolean
+ */
public static boolean hasHolderLeash(Entity entity) {
return getLeashData(entity).map(ILeashData::hasHolderLeash).orElse(false);
}
+ /**
+ * Gets all leashes.
+ *
+ * @param entity the entity
+ * @return the all leashes
+ */
public static Collection getAllLeashes(Entity entity) {
return getLeashData(entity).map(ILeashData::getAllLeashes).orElse(Collections.emptyList());
}
+ /**
+ * Is leashed by boolean.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @return the boolean
+ */
public static boolean isLeashedBy(Entity entity, Entity holder) {
return getLeashData(entity).map(data -> data.isLeashedBy(holder)).orElse(false);
}
+ /**
+ * Is leashed by boolean.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ * @return the boolean
+ */
public static boolean isLeashedBy(Entity entity, UUID holderUUID) {
return getLeashData(entity).map(data -> data.isLeashedBy(holderUUID)).orElse(false);
}
+ /**
+ * Is leashed by boolean.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ * @return the boolean
+ */
public static boolean isLeashedBy(Entity entity, BlockPos knotPos) {
return getLeashData(entity).map(data -> data.isLeashedBy(knotPos)).orElse(false);
}
+ /**
+ * Is in delayed leash boolean.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ * @return the boolean
+ */
public static boolean isInDelayedLeash(Entity entity, UUID holderUUID) {
return getLeashData(entity).map(data -> data.isInDelayedLeash(holderUUID)).orElse(false);
}
+ /**
+ * Gets leash info.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @return the leash info
+ */
public static Optional getLeashInfo(Entity entity, Entity holder) {
return getLeashData(entity).flatMap(data -> data.getLeashInfo(holder));
}
+ /**
+ * Gets leash info.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ * @return the leash info
+ */
public static Optional getLeashInfo(Entity entity, UUID holderUUID) {
return getLeashData(entity).flatMap(data -> data.getLeashInfo(holderUUID));
}
+ /**
+ * Gets leash info.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ * @return the leash info
+ */
public static Optional getLeashInfo(Entity entity, BlockPos knotPos) {
return getLeashData(entity).flatMap(data -> data.getLeashInfo(knotPos));
}
+ /**
+ * Can be leashed boolean.
+ *
+ * @param entity the entity
+ * @return the boolean
+ */
public static boolean canBeLeashed(Entity entity) {
return getLeashData(entity).map(ILeashData::canBeLeashed).orElse(false);
}
+ /**
+ * Can be attached to boolean.
+ *
+ * @param entity the entity
+ * @param target the target
+ * @return the boolean
+ */
public static boolean canBeAttachedTo(Entity entity, Entity target) {
return getLeashData(entity).map(data -> data.canBeAttachedTo(target)).orElse(false);
}
@@ -286,21 +719,45 @@ public final class LeashDataInnerAPI {
// ==================== 占用和同步 API ====================
+ /**
+ * The type Management operations.
+ */
public static final class ManagementOperations {
private ManagementOperations() {}
+ /**
+ * Occupy leash optional.
+ *
+ * @param entity the entity
+ * @return the optional
+ */
public static Optional occupyLeash(Entity entity) {
return getLeashData(entity).flatMap(ILeashData::occupyLeash);
}
+ /**
+ * Mark for sync.
+ *
+ * @param entity the entity
+ */
public static void markForSync(Entity entity) {
getLeashData(entity).ifPresent(ILeashData::markForSync);
}
+ /**
+ * Immediate sync.
+ *
+ * @param entity the entity
+ */
public static void immediateSync(Entity entity) {
getLeashData(entity).ifPresent(ILeashData::immediateSync);
}
+ /**
+ * Check sync.
+ *
+ * @param entity the entity
+ */
public static void checkSync(Entity entity) {
getLeashData(entity).ifPresent(ILeashData::checkSync);
}
@@ -308,9 +765,18 @@ public final class LeashDataInnerAPI {
// ==================== 工具方法 ====================
+ /**
+ * The type Utils.
+ */
public static final class Utils {
private Utils() {}
+ /**
+ * Has leash data boolean.
+ *
+ * @param entity the entity
+ * @return the boolean
+ */
public static boolean hasLeashData(Entity entity) {
return getLeashData(entity).isPresent();
}
diff --git a/src/main/java/top/r3944realms/superleadrope/util/capability/LeashStateInnerAPI.java b/src/main/java/top/r3944realms/superleadrope/util/capability/LeashStateInnerAPI.java
index ac2fd54..cb9bbb8 100644
--- a/src/main/java/top/r3944realms/superleadrope/util/capability/LeashStateInnerAPI.java
+++ b/src/main/java/top/r3944realms/superleadrope/util/capability/LeashStateInnerAPI.java
@@ -28,6 +28,9 @@ import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
+/**
+ * The type Leash state inner api.
+ */
@SuppressWarnings("unused")
@ApiStatus.Internal
public final class LeashStateInnerAPI {
@@ -35,6 +38,12 @@ public final class LeashStateInnerAPI {
private LeashStateInnerAPI() {
} // 防止实例化
+ /**
+ * Gets leash state.
+ *
+ * @param entity the entity
+ * @return the leash state
+ */
public static @NotNull Optional getLeashState(@NotNull Entity entity) {
Objects.requireNonNull(entity, "Entity cannot be null");
return entity.getCapability(SLPCapability.LEASH_STATE_CAP).resolve();
@@ -42,49 +51,119 @@ public final class LeashStateInnerAPI {
// ==================== 查询操作 ====================
+ /**
+ * The type Query.
+ */
public static final class Query {
private Query() {
}
+
+ /**
+ * Has leash state boolean.
+ *
+ * @param entity the entity
+ * @return the boolean
+ */
public static boolean hasLeashState(Entity entity) {
return getLeashState(entity).map(ILeashState::hasLeashState).orElse(false);
}
+ /**
+ * Gets all uuid states.
+ *
+ * @param entity the entity
+ * @return the all uuid states
+ */
public static Map getAllUUIDStates(Entity entity) {
return getLeashState(entity)
.map(ILeashState::getHolderLeashStates)
.orElse(Map.of());
}
+ /**
+ * Gets all block pos states.
+ *
+ * @param entity the entity
+ * @return the all block pos states
+ */
public static Map getAllBlockPosStates(Entity entity) {
return getLeashState(entity)
.map(ILeashState::getKnotLeashStates)
.orElse(Map.of());
}
+ /**
+ * Gets state.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @return the state
+ */
public static Optional getState(Entity entity, Entity holder) {
return getLeashState(entity).flatMap(state -> state.getLeashState(holder));
}
+ /**
+ * Gets state.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ * @return the state
+ */
public static Optional getState(Entity entity, UUID holderUUID) {
return getLeashState(entity).flatMap(state -> state.getLeashState(holderUUID));
}
+ /**
+ * Gets state.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ * @return the state
+ */
public static Optional getState(Entity entity, BlockPos knotPos) {
return getLeashState(entity).flatMap(state -> state.getLeashState(knotPos));
}
+ /**
+ * Has state boolean.
+ *
+ * @param entity the entity
+ * @return the boolean
+ */
public static boolean hasState(Entity entity) {
return getLeashState(entity).isPresent();
}
+ /**
+ * Has state for boolean.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @return the boolean
+ */
public static boolean hasStateFor(Entity entity, Entity holder) {
return getState(entity, holder).isPresent();
}
+ /**
+ * Has state for boolean.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ * @return the boolean
+ */
public static boolean hasStateFor(Entity entity, UUID holderUUID) {
return getState(entity, holderUUID).isPresent();
}
+ /**
+ * Has state for boolean.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ * @return the boolean
+ */
public static boolean hasStateFor(Entity entity, BlockPos knotPos) {
return getState(entity, knotPos).isPresent();
}
@@ -92,110 +171,265 @@ public final class LeashStateInnerAPI {
// ==================== 偏移量操作 ====================
+ /**
+ * The type Offset.
+ */
public static final class Offset {
private Offset() {
}
- // ---------------------- 重置操作 ----------------------
+ /**
+ * Reset all holder.
+ *
+ * @param entity the entity
+ */
+// ---------------------- 重置操作 ----------------------
public static void resetAllHolder(Entity entity) {
getLeashState(entity).ifPresent(ILeashState::resetAllLeashHolderLocationsOffset);
}
+ /**
+ * Reset holder for.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ */
public static void resetHolderFor(Entity entity, Entity holder) {
getLeashState(entity).ifPresent(state -> state.resetLeashHolderLocationOffset(holder));
}
+ /**
+ * Reset holder for.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ */
public static void resetHolderFor(Entity entity, UUID holderUUID) {
getLeashState(entity).ifPresent(state -> state.resetLeashHolderLocationOffset(holderUUID));
}
+ /**
+ * Reset holder for.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ */
public static void resetHolderFor(Entity entity, BlockPos knotPos) {
getLeashState(entity).ifPresent(state -> state.resetLeashHolderLocationOffset(knotPos));
}
- // ---------------------- 设置操作 ----------------------
+ /**
+ * Sets holder for.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @param offset the offset
+ */
+// ---------------------- 设置操作 ----------------------
public static void setHolderFor(Entity entity, Entity holder, Vec3 offset) {
getLeashState(entity).ifPresent(state -> state.setLeashHolderLocationOffset(holder, offset));
}
+ /**
+ * Sets holder for.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ * @param offset the offset
+ */
public static void setHolderFor(Entity entity, UUID holderUUID, Vec3 offset) {
getLeashState(entity).ifPresent(state -> state.setLeashHolderLocationOffset(holderUUID, offset));
}
+ /**
+ * Sets holder for.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ * @param offset the offset
+ */
public static void setHolderFor(Entity entity, BlockPos knotPos, Vec3 offset) {
getLeashState(entity).ifPresent(state -> state.setLeashHolderLocationOffset(knotPos, offset));
}
+ /**
+ * Sets holder for.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ */
public static void setHolderFor(Entity entity, BlockPos knotPos) {
getLeashState(entity).ifPresent(state -> state.setLeashHolderLocationOffset(knotPos, null));
}
+
+ /**
+ * Sets holder for.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ */
public static void setHolderFor(Entity entity, Entity holder) {
getLeashState(entity).ifPresent(state -> state.setLeashHolderLocationOffset(holder, null));
}
+ /**
+ * Sets holder for.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ */
public static void setHolderFor(Entity entity, UUID holderUUID) {
getLeashState(entity).ifPresent(state -> state.setLeashHolderLocationOffset(holderUUID, null));
}
- // ---------------------- 添加操作 ----------------------
+ /**
+ * Add holder to.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ * @param offset the offset
+ */
+// ---------------------- 添加操作 ----------------------
public static void addHolderTo(Entity entity, Entity holder, Vec3 offset) {
getLeashState(entity).ifPresent(state -> state.addLeashHolderLocationOffset(holder, offset));
}
+ /**
+ * Add holder to.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ * @param offset the offset
+ */
public static void addHolderTo(Entity entity, UUID holderUUID, Vec3 offset) {
getLeashState(entity).ifPresent(state -> state.addLeashHolderLocationOffset(holderUUID, offset));
}
+ /**
+ * Add holder to.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ * @param offset the offset
+ */
public static void addHolderTo(Entity entity, BlockPos knotPos, Vec3 offset) {
getLeashState(entity).ifPresent(state -> state.addLeashHolderLocationOffset(knotPos, offset));
}
- // ---------------------- 移除操作 ----------------------
+ /**
+ * Remove holder for.
+ *
+ * @param entity the entity
+ * @param holder the holder
+ */
+// ---------------------- 移除操作 ----------------------
public static void removeHolderFor(Entity entity, Entity holder) {
getLeashState(entity).ifPresent(state -> state.removeLeashHolderLocationOffset(holder));
}
+ /**
+ * Remove holder for.
+ *
+ * @param entity the entity
+ * @param holderUUID the holder uuid
+ */
public static void removeHolderFor(Entity entity, UUID holderUUID) {
getLeashState(entity).ifPresent(state -> state.removeLeashHolderLocationOffset(holderUUID));
}
+ /**
+ * Remove holder for.
+ *
+ * @param entity the entity
+ * @param knotPos the knot pos
+ */
public static void removeHolderFor(Entity entity, BlockPos knotPos) {
getLeashState(entity).ifPresent(state -> state.removeLeashHolderLocationOffset(knotPos));
}
+ /**
+ * Remove holder all.
+ *
+ * @param entity the entity
+ */
public static void removeHolderAll(Entity entity) {
getLeashState(entity).ifPresent(ILeashState::removeAllLeashHolderLocationOffset);
}
+ /**
+ * Remove all holder uui ds.
+ *
+ * @param entity the entity
+ */
public static void removeAllHolderUUIDs(Entity entity) {
getLeashState(entity).ifPresent(ILeashState::removeAllLeashHolderUUIDLocationOffset);
}
+ /**
+ * Remove all holder block poses.
+ *
+ * @param entity the entity
+ */
public static void removeAllHolderBlockPoses(Entity entity) {
getLeashState(entity).ifPresent(ILeashState::removeAllLeashHolderBlockPosLocationOffset);
}
+
+ /**
+ * Gets apply entity offset.
+ *
+ * @param entity the entity
+ * @return the apply entity offset
+ */
public static Optional getApplyEntityOffset(Entity entity) {
return getLeashState(entity).flatMap(ILeashState::getLeashApplyEntityLocationOffset);
}
+ /**
+ * Gets default apply entity offset.
+ *
+ * @param entity the entity
+ * @return the default apply entity offset
+ */
public static Vec3 getDefaultApplyEntityOffset(Entity entity) {
return getLeashState(entity)
.map(ILeashState::getDefaultLeashApplyEntityLocationOffset)
.orElse(Vec3.ZERO);
}
+ /**
+ * Reset apply entity all.
+ *
+ * @param entity the entity
+ */
public static void resetApplyEntityAll(Entity entity) {
getLeashState(entity).ifPresent(ILeashState::resetAllLeashApplyEntityLocationsOffset);
}
+ /**
+ * Remove apply entity.
+ *
+ * @param entity the entity
+ */
public static void removeApplyEntity(Entity entity) {
getLeashState(entity).ifPresent(ILeashState::removeLeashApplyEntityLocationOffset);
}
+ /**
+ * Sets apply entity.
+ *
+ * @param entity the entity
+ * @param offset the offset
+ */
public static void setApplyEntity(Entity entity, Vec3 offset) {
getLeashState(entity).ifPresent(state -> state.setLeashApplyEntityLocationOffset(offset));
}
+ /**
+ * Add apply entity.
+ *
+ * @param entity the entity
+ * @param offset the offset
+ */
public static void addApplyEntity(Entity entity, Vec3 offset) {
getLeashState(entity).ifPresent(state -> state.addLeashApplyEntityLocationOffset(offset));
}
@@ -204,18 +438,36 @@ public final class LeashStateInnerAPI {
// ==================== 同步操作 ====================
+ /**
+ * The type Sync.
+ */
public static final class Sync {
private Sync() {
}
+ /**
+ * Mark.
+ *
+ * @param entity the entity
+ */
public static void mark(Entity entity) {
getLeashState(entity).ifPresent(ILeashState::markForSync);
}
+ /**
+ * Immediate.
+ *
+ * @param entity the entity
+ */
public static void immediate(Entity entity) {
getLeashState(entity).ifPresent(ILeashState::immediateSync);
}
+ /**
+ * Check.
+ *
+ * @param entity the entity
+ */
public static void check(Entity entity) {
getLeashState(entity).ifPresent(ILeashState::checkSync);
}
@@ -223,10 +475,19 @@ public final class LeashStateInnerAPI {
// ==================== 高级操作 ====================
+ /**
+ * The type Operations.
+ */
public static final class Operations {
private Operations() {
}
+ /**
+ * Attach.
+ *
+ * @param leashed the leashed
+ * @param holder the holder
+ */
public static void attach(Entity leashed, Entity holder) {
getLeashState(leashed).ifPresent(state ->
state.setLeashHolderLocationOffset(holder,
@@ -234,18 +495,43 @@ public final class LeashStateInnerAPI {
);
}
+ /**
+ * Detach.
+ *
+ * @param leashed the leashed
+ * @param holder the holder
+ */
public static void detach(Entity leashed, Entity holder) {
Offset.removeHolderFor(leashed, holder);
}
+ /**
+ * Detach.
+ *
+ * @param leashed the leashed
+ * @param holderUUID the holder uuid
+ */
public static void detach(Entity leashed, UUID holderUUID) {
Offset.removeHolderFor(leashed, holderUUID);
}
+ /**
+ * Detach.
+ *
+ * @param leashed the leashed
+ * @param knotPos the knot pos
+ */
public static void detach(Entity leashed, BlockPos knotPos) {
Offset.removeHolderFor(leashed, knotPos);
}
+ /**
+ * Transfer.
+ *
+ * @param leashed the leashed
+ * @param oldHolder the old holder
+ * @param newHolder the new holder
+ */
public static void transfer(Entity leashed, Entity oldHolder, Entity newHolder) {
getLeashState(leashed).ifPresent(state -> {
state.removeLeashHolderLocationOffset(oldHolder);
@@ -254,6 +540,13 @@ public final class LeashStateInnerAPI {
});
}
+ /**
+ * Transfer.
+ *
+ * @param leashed the leashed
+ * @param oldHolderUUID the old holder uuid
+ * @param newHolder the new holder
+ */
public static void transfer(Entity leashed, UUID oldHolderUUID, Entity newHolder) {
getLeashState(leashed).ifPresent(state -> {
state.removeLeashHolderLocationOffset(oldHolderUUID);
@@ -262,6 +555,13 @@ public final class LeashStateInnerAPI {
});
}
+ /**
+ * Transfer.
+ *
+ * @param leashed the leashed
+ * @param oldKnotPos the old knot pos
+ * @param newHolder the new holder
+ */
public static void transfer(Entity leashed, BlockPos oldKnotPos, Entity newHolder) {
getLeashState(leashed).ifPresent(state -> {
state.removeLeashHolderLocationOffset(oldKnotPos);
@@ -270,6 +570,12 @@ public final class LeashStateInnerAPI {
});
}
+ /**
+ * Copy.
+ *
+ * @param source the source
+ * @param target the target
+ */
public static void copy(Entity source, Entity target) {
getLeashState(source).ifPresent(sourceState ->
getLeashState(target).ifPresent(targetState ->
diff --git a/src/main/java/top/r3944realms/superleadrope/util/file/ConfigUtil.java b/src/main/java/top/r3944realms/superleadrope/util/file/ConfigUtil.java
index 2bb9f30..c45a0c8 100644
--- a/src/main/java/top/r3944realms/superleadrope/util/file/ConfigUtil.java
+++ b/src/main/java/top/r3944realms/superleadrope/util/file/ConfigUtil.java
@@ -25,7 +25,15 @@ import top.r3944realms.superleadrope.SuperLeadRope;
import java.io.File;
import java.util.Optional;
+/**
+ * The type Config util.
+ */
public class ConfigUtil {
+ /**
+ * Create file.
+ *
+ * @param children the children
+ */
public static void createFile(String[] children) {//初始化配置文件目录
File configFile = new File(FMLPaths.CONFIGDIR.get().toFile(), SuperLeadRope.MOD_ID);
if (!configFile.exists()) {
@@ -48,6 +56,15 @@ public class ConfigUtil {
}
}
+ /**
+ * Register config.
+ *
+ * @param context the context
+ * @param type the type
+ * @param configSpec the config spec
+ * @param folderName the folder name
+ * @param fileName the file name
+ */
public static void registerConfig (
@NotNull ModLoadingContext context,
ModConfig.Type type,
diff --git a/src/main/java/top/r3944realms/superleadrope/util/lang/LanguageEnum.java b/src/main/java/top/r3944realms/superleadrope/util/lang/LanguageEnum.java
index 121004f..4ca1b2d 100644
--- a/src/main/java/top/r3944realms/superleadrope/util/lang/LanguageEnum.java
+++ b/src/main/java/top/r3944realms/superleadrope/util/lang/LanguageEnum.java
@@ -15,12 +15,30 @@
package top.r3944realms.superleadrope.util.lang;
+/**
+ * The enum Language enum.
+ */
public enum LanguageEnum {
+ /**
+ * English language enum.
+ */
English("en_us"),
+ /**
+ * Simple chinese language enum.
+ */
SimpleChinese("zh_cn"),
+ /**
+ * Traditional chinese language enum.
+ */
TraditionalChinese("zh_tw"),
+ /**
+ * Literary chinese language enum.
+ */
LiteraryChinese("lzh"),
;
+ /**
+ * The Local.
+ */
public final String local;
LanguageEnum(String local) {
this.local = local;
diff --git a/src/main/java/top/r3944realms/superleadrope/util/lang/ModPartEnum.java b/src/main/java/top/r3944realms/superleadrope/util/lang/ModPartEnum.java
index 84e8774..1e14489 100644
--- a/src/main/java/top/r3944realms/superleadrope/util/lang/ModPartEnum.java
+++ b/src/main/java/top/r3944realms/superleadrope/util/lang/ModPartEnum.java
@@ -15,24 +15,81 @@
package top.r3944realms.superleadrope.util.lang;
+/**
+ * The enum Mod part enum.
+ */
public enum ModPartEnum {
+ /**
+ * Default mod part enum.
+ */
DEFAULT,
+ /**
+ * Item mod part enum.
+ */
ITEM,
+ /**
+ * Block mod part enum.
+ */
BLOCK,
+ /**
+ * Enchantment mod part enum.
+ */
ENCHANTMENT,
+ /**
+ * Advancement mod part enum.
+ */
ADVANCEMENT,
+ /**
+ * Creative tab mod part enum.
+ */
CREATIVE_TAB,
+ /**
+ * Config mod part enum.
+ */
CONFIG,
+ /**
+ * Entity mod part enum.
+ */
ENTITY,
+ /**
+ * Gui mod part enum.
+ */
GUI,
+ /**
+ * Author mod part enum.
+ */
AUTHOR,
+ /**
+ * Title mod part enum.
+ */
TITLE,
+ /**
+ * Name mod part enum.
+ */
NAME,
+ /**
+ * Game rule mod part enum.
+ */
GAME_RULE,
+ /**
+ * Description mod part enum.
+ */
DESCRIPTION,
+ /**
+ * Info mod part enum.
+ */
INFO,
+ /**
+ * Message mod part enum.
+ */
MESSAGE,
+ /**
+ * Command mod part enum.
+ */
COMMAND,
+ /**
+ * Sound mod part enum.
+ */
SOUND
}
diff --git a/src/main/java/top/r3944realms/superleadrope/util/model/RidingRelationship.java b/src/main/java/top/r3944realms/superleadrope/util/model/RidingRelationship.java
index 9f0a7dd..9683bd5 100644
--- a/src/main/java/top/r3944realms/superleadrope/util/model/RidingRelationship.java
+++ b/src/main/java/top/r3944realms/superleadrope/util/model/RidingRelationship.java
@@ -25,46 +25,93 @@ public class RidingRelationship {
private UUID vehicleId;
private List passengers;
+ /**
+ * Instantiates a new Riding relationship.
+ */
public RidingRelationship() {
this.passengers = new ArrayList<>();
}
+ /**
+ * Instantiates a new Riding relationship.
+ *
+ * @param passengers the passengers
+ * @param vehicleId the vehicle id
+ * @param entityId the entity id
+ */
public RidingRelationship(List passengers, UUID vehicleId, UUID entityId) {
this.passengers = passengers != null ? passengers : new ArrayList<>();
this.vehicleId = vehicleId;
this.entityId = entityId;
}
+ /**
+ * Gets entity id.
+ *
+ * @return the entity id
+ */
public UUID getEntityId() {
return entityId;
}
+ /**
+ * Sets entity id.
+ *
+ * @param entityId the entity id
+ */
public void setEntityId(UUID entityId) {
this.entityId = entityId;
}
+ /**
+ * Gets passengers.
+ *
+ * @return the passengers
+ */
public List getPassengers() {
return Collections.unmodifiableList(passengers);
}
+ /**
+ * Sets passengers.
+ *
+ * @param passengers the passengers
+ */
public void setPassengers(List passengers) {
this.passengers = passengers != null ? passengers : new ArrayList<>();
}
+ /**
+ * Add passenger.
+ *
+ * @param passenger the passenger
+ */
public void addPassenger(RidingRelationship passenger) {
this.passengers.add(passenger);
}
+ /**
+ * Gets vehicle id.
+ *
+ * @return the vehicle id
+ */
public UUID getVehicleId() {
return vehicleId;
}
+ /**
+ * Sets vehicle id.
+ *
+ * @param vehicleId the vehicle id
+ */
public void setVehicleId(UUID vehicleId) {
this.vehicleId = vehicleId;
}
/**
* 获取所有嵌套乘客的数量
+ *
+ * @return the total passenger count
*/
public int getTotalPassengerCount() {
int count = passengers.size();
@@ -76,6 +123,9 @@ public class RidingRelationship {
/**
* 检查是否包含特定实体
+ *
+ * @param entityId the entity id
+ * @return the boolean
*/
public boolean containsEntity(UUID entityId) {
if (Objects.equals(this.entityId, entityId)) {
diff --git a/src/main/java/top/r3944realms/superleadrope/util/nbt/NBTReader.java b/src/main/java/top/r3944realms/superleadrope/util/nbt/NBTReader.java
index c51c238..89bf38d 100644
--- a/src/main/java/top/r3944realms/superleadrope/util/nbt/NBTReader.java
+++ b/src/main/java/top/r3944realms/superleadrope/util/nbt/NBTReader.java
@@ -18,8 +18,18 @@ package top.r3944realms.superleadrope.util.nbt;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.phys.Vec3;
+/**
+ * The type Nbt reader.
+ */
public class NBTReader {
private NBTReader() {}
+
+ /**
+ * Read vec 3 vec 3.
+ *
+ * @param nbt the nbt
+ * @return the vec 3
+ */
public static Vec3 readVec3(CompoundTag nbt) {
if (nbt.contains("X") && nbt.contains("Y") && nbt.contains("Z")) {
return new Vec3(
diff --git a/src/main/java/top/r3944realms/superleadrope/util/nbt/NBTWriter.java b/src/main/java/top/r3944realms/superleadrope/util/nbt/NBTWriter.java
index a3284b2..e81ca18 100644
--- a/src/main/java/top/r3944realms/superleadrope/util/nbt/NBTWriter.java
+++ b/src/main/java/top/r3944realms/superleadrope/util/nbt/NBTWriter.java
@@ -18,8 +18,18 @@ package top.r3944realms.superleadrope.util.nbt;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.phys.Vec3;
+/**
+ * The type Nbt writer.
+ */
public class NBTWriter {
private NBTWriter() {}
+
+ /**
+ * Write vec 3 compound tag.
+ *
+ * @param vec the vec
+ * @return the compound tag
+ */
public static CompoundTag writeVec3(Vec3 vec) {
CompoundTag nbt = new CompoundTag();
if (vec == null) throw new IllegalArgumentException("Vec3 cannot be null");
diff --git a/src/main/java/top/r3944realms/superleadrope/util/riding/RidingApplier.java b/src/main/java/top/r3944realms/superleadrope/util/riding/RidingApplier.java
index 7078e6b..404053a 100644
--- a/src/main/java/top/r3944realms/superleadrope/util/riding/RidingApplier.java
+++ b/src/main/java/top/r3944realms/superleadrope/util/riding/RidingApplier.java
@@ -27,12 +27,16 @@ import java.util.Queue;
import java.util.UUID;
import java.util.function.Function;
+/**
+ * The type Riding applier.
+ */
public class RidingApplier {
/**
* 应用骑乘关系(在服务器端调用)
- * @param relationship 骑乘关系
+ *
+ * @param relationship 骑乘关系
* @param entityProvider 实体提供器(根据UUID获取实体)
- * @return 应用成功的实体数量
+ * @return 应用成功的实体数量 int
*/
public static int applyRidingRelationship(RidingRelationship relationship,
Function entityProvider) {
@@ -92,8 +96,12 @@ public class RidingApplier {
return appliedCount;
}
+
/**
* 批量应用骑乘关系(适用于世界加载时)
+ *
+ * @param relationships the relationships
+ * @param entityProvider the entity provider
*/
public static void applyRidingRelationships(Collection relationships,
Function entityProvider) {
@@ -113,6 +121,10 @@ public class RidingApplier {
/**
* 从JSON字符串应用骑乘关系
+ *
+ * @param json the json
+ * @param entityProvider the entity provider
+ * @return the int
*/
public static int applyRidingRelationshipFromJson(String json,
Function entityProvider) {
diff --git a/src/main/java/top/r3944realms/superleadrope/util/riding/RidingDismounts.java b/src/main/java/top/r3944realms/superleadrope/util/riding/RidingDismounts.java
index e695d15..3f13685 100644
--- a/src/main/java/top/r3944realms/superleadrope/util/riding/RidingDismounts.java
+++ b/src/main/java/top/r3944realms/superleadrope/util/riding/RidingDismounts.java
@@ -21,9 +21,14 @@ import top.r3944realms.superleadrope.util.model.RidingRelationship;
import java.util.*;
import java.util.function.Function;
+/**
+ * The type Riding dismounts.
+ */
public class RidingDismounts {
/**
* 解除单个实体的骑乘关系
+ *
+ * @param entity the entity
*/
public static void dismountEntity(Entity entity) {
if (entity == null) {
@@ -41,6 +46,8 @@ public class RidingDismounts {
/**
* 解除实体及其所有乘客的骑乘关系(非递归)
+ *
+ * @param entity the entity
*/
public static void dismountAllPassengers(Entity entity) {
if (entity == null) {
@@ -65,6 +72,8 @@ public class RidingDismounts {
/**
* 解除根实体的骑乘关系(包括从载具下车)
+ *
+ * @param entity the entity
*/
public static void dismountRootEntity(Entity entity) {
if (entity == null) {
@@ -86,6 +95,10 @@ public class RidingDismounts {
/**
* 安全解除骑乘关系(带超时保护)
+ *
+ * @param entity the entity
+ * @param maxIterations the max iterations
+ * @return the boolean
*/
public static boolean safeDismountAll(Entity entity, int maxIterations) {
if (entity == null) {
@@ -118,6 +131,8 @@ public class RidingDismounts {
/**
* 批量解除多个实体的骑乘关系
+ *
+ * @param entities the entities
*/
public static void dismountEntities(Collection entities) {
if (entities == null || entities.isEmpty()) {
@@ -151,6 +166,9 @@ public class RidingDismounts {
/**
* 根据骑乘关系数据结构解除骑乘
+ *
+ * @param relationship the relationship
+ * @param entityProvider the entity provider
*/
public static void dismountByRelationship(RidingRelationship relationship,
Function entityProvider) {
@@ -181,6 +199,8 @@ public class RidingDismounts {
/**
* 立即解除所有骑乘关系(强制方式)
+ *
+ * @param entity the entity
*/
public static void forceDismountAll(Entity entity) {
if (entity == null) {
diff --git a/src/main/java/top/r3944realms/superleadrope/util/riding/RidingFinder.java b/src/main/java/top/r3944realms/superleadrope/util/riding/RidingFinder.java
index 2ae5f5e..b62e696 100644
--- a/src/main/java/top/r3944realms/superleadrope/util/riding/RidingFinder.java
+++ b/src/main/java/top/r3944realms/superleadrope/util/riding/RidingFinder.java
@@ -22,9 +22,16 @@ import javax.annotation.Nullable;
import java.util.*;
import java.util.function.Function;
+/**
+ * The type Riding finder.
+ */
public class RidingFinder {
/**
* 从JSON字符串应用骑乘关系
+ *
+ * @param ship the ship
+ * @param entityProvider the entity provider
+ * @return the entity from riding ship
*/
public static List getEntityFromRidingShip(RidingRelationship ship,
Function entityProvider) {
@@ -41,8 +48,12 @@ public class RidingFinder {
}
return ret;
}
+
/**
* 查找根载具
+ *
+ * @param entity the entity
+ * @return the entity
*/
@Nullable
public static Entity findRootVehicle(@Nullable Entity entity) {
@@ -63,6 +74,9 @@ public class RidingFinder {
/**
* 获取所有乘客(包括嵌套乘客)
+ *
+ * @param entity the entity
+ * @return the all passengers
*/
public static List getAllPassengers(@Nullable Entity entity) {
return getAllPassengers(entity, true);
@@ -70,6 +84,10 @@ public class RidingFinder {
/**
* 获取所有乘客(包括嵌套乘客)
+ *
+ * @param entity the entity
+ * @param findRoot the find root
+ * @return the all passengers
*/
public static List getAllPassengers(@Nullable Entity entity, boolean findRoot) {
if (entity == null) {
diff --git a/src/main/java/top/r3944realms/superleadrope/util/riding/RidingSaver.java b/src/main/java/top/r3944realms/superleadrope/util/riding/RidingSaver.java
index d4fd663..542d6ca 100644
--- a/src/main/java/top/r3944realms/superleadrope/util/riding/RidingSaver.java
+++ b/src/main/java/top/r3944realms/superleadrope/util/riding/RidingSaver.java
@@ -26,9 +26,15 @@ import javax.annotation.Nullable;
import java.util.*;
import java.util.function.Function;
+/**
+ * The type Riding saver.
+ */
public class RidingSaver {
/**
* 保存骑乘关系
+ *
+ * @param entity the entity
+ * @return the riding relationship
*/
public static RidingRelationship save(@Nullable Entity entity) {
return save(entity, true);
@@ -36,6 +42,10 @@ public class RidingSaver {
/**
* 保存骑乘关系
+ *
+ * @param entity the entity
+ * @param findRoot the find root
+ * @return the riding relationship
*/
public static RidingRelationship save(@Nullable Entity entity, boolean findRoot) {
if (entity == null) {
@@ -98,9 +108,13 @@ public class RidingSaver {
return rootRelationship;
}
+
/**
* 过滤骑乘关系,只保留白名单根节点及其合法子树
* 如果根节点不在白名单,则回退到第一个合法父节点
+ *
+ * @param relationship the relationship
+ * @return the riding relationship
*/
public static RidingRelationship filterByWhitelistRoot(RidingRelationship relationship) {
if (relationship == null) return null;
@@ -145,6 +159,11 @@ public class RidingSaver {
// 传入一个实体提供器 Function,通常在服务器侧就是 level::getEntity
private static Function entityProvider;
+ /**
+ * Sets entity provider.
+ *
+ * @param provider the provider
+ */
public static void setEntityProvider(Function provider) {
entityProvider = provider;
}
diff --git a/src/main/java/top/r3944realms/superleadrope/util/riding/RidingSerializer.java b/src/main/java/top/r3944realms/superleadrope/util/riding/RidingSerializer.java
index bea0368..2e7b178 100644
--- a/src/main/java/top/r3944realms/superleadrope/util/riding/RidingSerializer.java
+++ b/src/main/java/top/r3944realms/superleadrope/util/riding/RidingSerializer.java
@@ -18,10 +18,17 @@ package top.r3944realms.superleadrope.util.riding;
import com.google.gson.Gson;
import top.r3944realms.superleadrope.util.model.RidingRelationship;
+/**
+ * The type Riding serializer.
+ */
public class RidingSerializer {
private static final Gson GSON = new Gson();
+
/**
* 序列化骑乘关系
+ *
+ * @param relationship the relationship
+ * @return the string
*/
public static String serialize(RidingRelationship relationship) {
return GSON.toJson(relationship);
@@ -29,6 +36,9 @@ public class RidingSerializer {
/**
* 反序列化骑乘关系
+ *
+ * @param json the json
+ * @return the riding relationship
*/
public static RidingRelationship deserialize(String json) {
return GSON.fromJson(json, RidingRelationship.class);
diff --git a/src/main/java/top/r3944realms/superleadrope/util/riding/RidingValidator.java b/src/main/java/top/r3944realms/superleadrope/util/riding/RidingValidator.java
index 7c20369..0f92563 100644
--- a/src/main/java/top/r3944realms/superleadrope/util/riding/RidingValidator.java
+++ b/src/main/java/top/r3944realms/superleadrope/util/riding/RidingValidator.java
@@ -20,9 +20,16 @@ import net.minecraft.world.entity.Entity;
import java.util.LinkedList;
import java.util.Queue;
+/**
+ * The type Riding validator.
+ */
public class RidingValidator {
/**
* 检查骑乘是否会产生循环引用
+ *
+ * @param entity the entity
+ * @param vehicle the vehicle
+ * @return the boolean
*/
public static boolean wouldCreateCycle(Entity entity, Entity vehicle) {
// 如果实体就是载具本身,直接产生循环
@@ -36,6 +43,10 @@ public class RidingValidator {
/**
* 检查target是否是entity的间接乘客
+ *
+ * @param target the target
+ * @param entity the entity
+ * @return the boolean
*/
public static boolean isIndirectPassenger(Entity target, Entity entity) {
Queue queue = new LinkedList<>();
diff --git a/src/main/java/top/r3944realms/superleadrope/util/riding/RindingLeash.java b/src/main/java/top/r3944realms/superleadrope/util/riding/RindingLeash.java
index a543611..27f448d 100644
--- a/src/main/java/top/r3944realms/superleadrope/util/riding/RindingLeash.java
+++ b/src/main/java/top/r3944realms/superleadrope/util/riding/RindingLeash.java
@@ -25,9 +25,15 @@ import top.r3944realms.superleadrope.CommonEventHandler;
import top.r3944realms.superleadrope.network.NetworkHandler;
import top.r3944realms.superleadrope.network.toClient.UpdatePlayerMovementPacket;
+/**
+ * The type Rinding leash.
+ */
public class RindingLeash {
/**
* 获取乘坐链中第一个在白名单的载具,如果没有则返回null
+ *
+ * @param entity the entity
+ * @return the safe whitelist root
*/
@Nullable
public static Entity getSafeWhitelistRoot(Entity entity) {
@@ -50,6 +56,10 @@ public class RindingLeash {
* 获取最终可作用的载具,用于拴绳合力应用。
* 当链条中没有白名单载具时解除骑乘并返回自身
* 仅在拴绳合力不为零时调用
+ *
+ * @param entity the entity
+ * @param hasForce the has force
+ * @return the final entity for leash if force
*/
public static Entity getFinalEntityForLeashIfForce(Entity entity, boolean hasForce) {
if (!hasForce || entity == null) {
@@ -75,6 +85,9 @@ public class RindingLeash {
/**
* 给动物应用拴绳力前的移动控制保护
+ *
+ * @param entity the entity
+ * @param hasLeash the has leash
*/
public static void protectAnimalMovement(Entity entity, boolean hasLeash) {
if (entity instanceof Animal mob) {
@@ -89,6 +102,12 @@ public class RindingLeash {
/**
* 给玩家应用拴绳力前的发包处理
+ *
+ * @param player the player
+ * @param leashVec the leash vec
+ * @param k the k
+ * @param dampingFactor the damping factor
+ * @param maxForce the max force
*/
public static void applyForceToPlayer(ServerPlayer player, Vec3 leashVec, double k, double dampingFactor, double maxForce) {
Vec3 velocity = player.getDeltaMovement();
diff --git a/src/main/java/top/r3944realms/superleadrope/workspace/LeashHelper.java b/src/main/java/top/r3944realms/superleadrope/workspace/LeashHelper.java
index 05a5e5e..82adbbf 100644
--- a/src/main/java/top/r3944realms/superleadrope/workspace/LeashHelper.java
+++ b/src/main/java/top/r3944realms/superleadrope/workspace/LeashHelper.java
@@ -16,6 +16,7 @@
package top.r3944realms.superleadrope.workspace;
import net.minecraft.world.entity.Entity;
+import net.minecraft.world.phys.AABB;
import top.r3944realms.superleadrope.CommonEventHandler;
import top.r3944realms.superleadrope.api.SLPCapability;
import top.r3944realms.superleadrope.api.SuperLeadRopeApi;
@@ -26,8 +27,12 @@ import top.r3944realms.superleadrope.util.capability.LeashDataInnerAPI;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
+import java.util.function.Predicate;
import java.util.stream.Collectors;
+/**
+ * The type Leash helper.
+ */
public class LeashHelper implements ILeashHelper {
@Override
public IHolder getHolderHelper(Entity holder) {
@@ -38,7 +43,7 @@ public class LeashHelper implements ILeashHelper {
}
@Override
- public Set getAllLeashData() {
+ public Set getAllLeash() {
return SuperLeadRopeApi.leashableInArea(getHolderEntity())
.stream()
.map(i -> i.getCapability(SLPCapability.LEASH_DATA_CAP).resolve())
@@ -47,6 +52,16 @@ public class LeashHelper implements ILeashHelper {
.collect(Collectors.toSet());
}
+ @Override
+ public Set getLeash(Class clazz, AABB box, Predicate filter) {
+ return SuperLeadRopeApi.leashableInArea(getHolderEntity(), clazz, box, filter)
+ .stream()
+ .map(i -> i.getCapability(SLPCapability.LEASH_DATA_CAP).resolve())
+ .filter(Optional::isPresent)
+ .map(Optional::get)
+ .collect(Collectors.toSet());
+ }
+
@Override
public boolean leashEntity(UUID uuid) {
Entity entity = CommonEventHandler.Game.getServerLevel().getEntity(uuid);
diff --git a/src/main/java/top/r3944realms/superleadrope/workspace/WorkSpaceHelper.java b/src/main/java/top/r3944realms/superleadrope/workspace/WorkSpaceHelper.java
index 629e0cd..1213d17 100644
--- a/src/main/java/top/r3944realms/superleadrope/workspace/WorkSpaceHelper.java
+++ b/src/main/java/top/r3944realms/superleadrope/workspace/WorkSpaceHelper.java
@@ -21,6 +21,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import top.r3944realms.superleadrope.api.type.capabilty.ILeashData;
import top.r3944realms.superleadrope.api.type.capabilty.ILeashState;
import top.r3944realms.superleadrope.api.type.util.ILeashHelper;
@@ -31,14 +32,23 @@ import top.r3944realms.superleadrope.util.capability.LeashDataInnerAPI;
import top.r3944realms.superleadrope.util.capability.LeashStateInnerAPI;
import java.util.List;
+import java.util.Objects;
import java.util.Optional;
import java.util.function.Predicate;
+/**
+ * The type Work space helper.
+ */
public class WorkSpaceHelper implements IWorkSpaceHelper {
@Override
- public @NotNull List leashableInArea(@NotNull Level pLevel, Vec3 pPos, Predicate filter, double fetchDistance) {
+ public @NotNull List leashableInArea(@NotNull Level pLevel, Vec3 pPos, @Nullable Predicate filter, double fetchDistance) {
AABB box = AABB.ofSize(pPos, fetchDistance, fetchDistance, fetchDistance);
- return pLevel.getEntitiesOfClass(Entity.class, box, e -> LeashDataImpl.isLeashable(e) && filter.test(e));
+ return pLevel.getEntitiesOfClass(Entity.class, box, e -> LeashDataImpl.isLeashable(e) && Objects.requireNonNullElse(filter, entity -> true).test(e));
+ }
+
+ @Override
+ public @NotNull List leashableInArea(@NotNull Level pLevel, Class clazz, @Nullable Predicate