添加了javadoc, 调整API,添加self方法
This commit is contained in:
parent
a24314789a
commit
6553f04b4e
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -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/
|
||||
|
|
|
|||
8
.idea/.gitignore
vendored
8
.idea/.gitignore
vendored
|
|
@ -1,8 +0,0 @@
|
|||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
<component name="CopyrightManager">
|
||||
<settings>
|
||||
<module2copyright>
|
||||
<element module="All" copyright="GPLv3" />
|
||||
</module2copyright>
|
||||
<LanguageOptions name="JAVA">
|
||||
<option name="fileTypeOverride" value="3" />
|
||||
</LanguageOptions>
|
||||
</settings>
|
||||
</component>
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="LOCAL" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleHome" value="$PROJECT_DIR$/../../projEnv/gradle/gradle-8.14.2" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,net.minecraft.world.entity.Entity,level" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="ClassCanBeRecord" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
||||
|
|
@ -1,204 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaDocConfiguration">
|
||||
<GENERAL>
|
||||
<MODE>UPDATE</MODE>
|
||||
<OVERRIDDEN_METHODS>false</OVERRIDDEN_METHODS>
|
||||
<SPLITTED_CLASS_NAME>true</SPLITTED_CLASS_NAME>
|
||||
<LEVELS>
|
||||
<LEVEL>TYPE</LEVEL>
|
||||
<LEVEL>METHOD</LEVEL>
|
||||
<LEVEL>FIELD</LEVEL>
|
||||
</LEVELS>
|
||||
<VISIBILITIES>
|
||||
<VISIBILITY>PUBLIC</VISIBILITY>
|
||||
<VISIBILITY>PROTECTED</VISIBILITY>
|
||||
<VISIBILITY>DEFAULT</VISIBILITY>
|
||||
</VISIBILITIES>
|
||||
</GENERAL>
|
||||
<TEMPLATES>
|
||||
<CLASSES>
|
||||
<CLASS>
|
||||
<KEY>^.*(public|protected|private)*.+interface\s+\w+.*</KEY>
|
||||
<VALUE>/**\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>
|
||||
*/</VALUE>
|
||||
</CLASS>
|
||||
<CLASS>
|
||||
<KEY>^.*(public|protected|private)*.+enum\s+\w+.*</KEY>
|
||||
<VALUE>/**\n
|
||||
* The enum ${name}.\n
|
||||
*/</VALUE>
|
||||
</CLASS>
|
||||
<CLASS>
|
||||
<KEY>^.*(public|protected|private)*.+class\s+\w+.*</KEY>
|
||||
<VALUE>/**\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>
|
||||
*/</VALUE>
|
||||
</CLASS>
|
||||
<CLASS>
|
||||
<KEY>.+</KEY>
|
||||
<VALUE>/**\n
|
||||
* The type ${name}.\n
|
||||
*/</VALUE>
|
||||
</CLASS>
|
||||
</CLASSES>
|
||||
<CONSTRUCTORS>
|
||||
<CONSTRUCTOR>
|
||||
<KEY>.+</KEY>
|
||||
<VALUE>/**\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>
|
||||
*/</VALUE>
|
||||
</CONSTRUCTOR>
|
||||
</CONSTRUCTORS>
|
||||
<METHODS>
|
||||
<METHOD>
|
||||
<KEY>^.*(public|protected|private)*\s*.*(\w(\s*<.+>)*)+\s+get\w+\s*\(.*\).+</KEY>
|
||||
<VALUE>/**\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>
|
||||
*/</VALUE>
|
||||
</METHOD>
|
||||
<METHOD>
|
||||
<KEY>^.*(public|protected|private)*\s*.*(void|\w(\s*<.+>)*)+\s+set\w+\s*\(.*\).+</KEY>
|
||||
<VALUE>/**\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>
|
||||
*/</VALUE>
|
||||
</METHOD>
|
||||
<METHOD>
|
||||
<KEY>^.*((public\s+static)|(static\s+public))\s+void\s+main\s*\(\s*String\s*(\[\s*\]|\.\.\.)\s+\w+\s*\).+</KEY>
|
||||
<VALUE>/**\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>
|
||||
*/</VALUE>
|
||||
</METHOD>
|
||||
<METHOD>
|
||||
<KEY>.+</KEY>
|
||||
<VALUE>/**\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>
|
||||
*/</VALUE>
|
||||
</METHOD>
|
||||
</METHODS>
|
||||
<FIELDS>
|
||||
<FIELD>
|
||||
<KEY>^.*(public|protected|private)*.+static.*(\w\s\w)+.+</KEY>
|
||||
<VALUE>/**\n
|
||||
* The constant ${element.getName()}.\n
|
||||
*/</VALUE>
|
||||
</FIELD>
|
||||
<FIELD>
|
||||
<KEY>^.*(public|protected|private)*.*(\w\s\w)+.+</KEY>
|
||||
<VALUE>/**\n
|
||||
<#if element.parent.isInterface()>
|
||||
* The constant ${element.getName()}.\n
|
||||
<#else>
|
||||
* The ${name}.\n
|
||||
</#if> */</VALUE>
|
||||
</FIELD>
|
||||
<FIELD>
|
||||
<KEY>.+</KEY>
|
||||
<VALUE>/**\n
|
||||
<#if element.parent.isEnum()>
|
||||
*${name} ${typeName}.\n
|
||||
<#else>
|
||||
* The ${name}.\n
|
||||
</#if>*/</VALUE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TEMPLATES>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ASMIdeaPluginConfiguration">
|
||||
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
|
||||
<groovy codeStyle="LEGACY" />
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Client" type="Application" factoryName="Application">
|
||||
<envs>
|
||||
<env name="MOD_CLASSES" value="superleadrope%%G:\WhimsyMod\SuperLeadRope\build\classes\java\main;superleadrope%%G:\WhimsyMod\SuperLeadRope\build\resources\main" />
|
||||
</envs>
|
||||
<option name="MAIN_CLASS_NAME" value="net.neoforged.devlaunch.Main" />
|
||||
<module name="SuperLeadRope.main" />
|
||||
<option name="PROGRAM_PARAMETERS" value="@G:\\WhimsyMod\\SuperLeadRope\\build\\moddev\\clientRunProgramArgs.txt" />
|
||||
<option name="VM_PARAMETERS" value="@G:\\WhimsyMod\\SuperLeadRope\\build\\moddev\\clientRunVmArgs.txt -Dfml.modFolders=superleadrope%%G:\\WhimsyMod\\SuperLeadRope\\build\\classes\\java\\main;superleadrope%%G:\\WhimsyMod\\SuperLeadRope\\build\\resources\\main" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/run" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="RemoteDebug" type="Remote">
|
||||
<module name="SuperLeadRope.main" />
|
||||
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
||||
<option name="SERVER_MODE" value="false" />
|
||||
<option name="SHMEM_ADDRESS" value="javadebug" />
|
||||
<option name="HOST" value="localhost" />
|
||||
<option name="PORT" value="5005" />
|
||||
<option name="AUTO_RESTART" value="false" />
|
||||
<RunnerSettings RunnerId="Debug">
|
||||
<option name="DEBUG_PORT" value="5005" />
|
||||
<option name="LOCAL" value="false" />
|
||||
</RunnerSettings>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
|
|
@ -1,124 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Remote Debug" type="Remote">
|
||||
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
||||
<option name="SERVER_MODE" value="false" />
|
||||
<option name="SHMEM_ADDRESS" value="javadebug" />
|
||||
<option name="HOST" value="localhost" />
|
||||
<option name="PORT" value="5005" />
|
||||
<option name="AUTO_RESTART" value="false" />
|
||||
<RunnerSettings RunnerId="Debug">
|
||||
<option name="DEBUG_PORT" value="5005" />
|
||||
<option name="LOCAL" value="false" />
|
||||
</RunnerSettings>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
|
|
@ -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<CommandSourceStack> 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) {
|
||||
|
|
|
|||
|
|
@ -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 的元数据
|
||||
|
|
|
|||
|
|
@ -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<ILeashData> LEASH_DATA_CAP = CapabilityManager.get(new CapabilityToken<>(){});
|
||||
/**
|
||||
* The constant LEASH_STATE_CAP.
|
||||
*/
|
||||
public static final Capability<ILeashState> LEASH_STATE_CAP = CapabilityManager.get(new CapabilityToken<>() {});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Entity> leashableInArea(Level pLevel, Vec3 pPos, Predicate<Entity> 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<Entity> leashableInArea(@NotNull Entity entity, Predicate<Entity> 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<Entity> leashableInArea(@NotNull Level pLevel, Vec3 pPos, Predicate<Entity> 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<Entity> leashableInArea(Entity entity, Predicate<Entity> filter) {
|
||||
return leashableInArea(entity, filter, 1024D);
|
||||
}
|
||||
|
||||
/**
|
||||
* Leashable in area list.
|
||||
*
|
||||
* @param holder the holder
|
||||
* @return the list
|
||||
*/
|
||||
public static @NotNull List<Entity> 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<Entity> leashableInArea(Entity holder, Class<Entity> clazz, AABB box, Predicate<Entity> 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<ILeashState> getLeashState(Entity pEntity) {
|
||||
return Services.WORK_SPACE.getLeashState(pEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets leash data.
|
||||
*
|
||||
* @param pEntity the p entity
|
||||
* @return the leash data
|
||||
*/
|
||||
public static Optional<ILeashData> getLeashData(Entity pEntity) {
|
||||
return Services.WORK_SPACE.getLeashData(pEntity);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<BlockPos, LeashInfo> 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<UUID, LeashInfo> vaildLeashHolders, Map<BlockPos, LeashInfo> 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<UUID, LeashInfo> getVaildLeashHolders() {
|
||||
return vaildLeashHolders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets vaild leash knots.
|
||||
*
|
||||
* @return the vaild leash knots
|
||||
*/
|
||||
public Map<BlockPos, LeashInfo> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,122 +30,609 @@ import java.util.UUID;
|
|||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public interface ILeashData extends INBTSerializable<CompoundTag> {
|
||||
/**
|
||||
* 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<LeashInfo> 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<LeashInfo> getLeashInfo(Entity holder);
|
||||
|
||||
/**
|
||||
* Gets leash info.
|
||||
*
|
||||
* @param holderUUID the holder uuid
|
||||
* @return the leash info
|
||||
*/
|
||||
Optional<LeashInfo> getLeashInfo(UUID holderUUID);
|
||||
|
||||
/**
|
||||
* Gets leash info.
|
||||
*
|
||||
* @param knotPos the knot pos
|
||||
* @return the leash info
|
||||
*/
|
||||
Optional<LeashInfo> 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<UUID> occupyLeash();
|
||||
|
||||
/**
|
||||
* Mark for sync.
|
||||
*/
|
||||
void markForSync();
|
||||
|
||||
/**
|
||||
* Immediate sync.
|
||||
*/
|
||||
void immediateSync();
|
||||
|
||||
/**
|
||||
* Check sync.
|
||||
*/
|
||||
void checkSync();
|
||||
|
||||
}
|
||||
|
|
@ -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<CompoundTag> {
|
||||
/**
|
||||
* 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<UUID, LeashState> getHolderLeashStates();
|
||||
|
||||
/**
|
||||
* Gets knot leash states.
|
||||
*
|
||||
* @return the knot leash states
|
||||
*/
|
||||
Map<BlockPos, LeashState> getKnotLeashStates();
|
||||
|
||||
/**
|
||||
* Gets leash state.
|
||||
*
|
||||
* @param entity the entity
|
||||
* @return the leash state
|
||||
*/
|
||||
Optional<LeashState> getLeashState(Entity entity);
|
||||
|
||||
/**
|
||||
* Gets leash state.
|
||||
*
|
||||
* @param uuid the uuid
|
||||
* @return the leash state
|
||||
*/
|
||||
Optional<LeashState> getLeashState(UUID uuid);
|
||||
|
||||
/**
|
||||
* Gets leash state.
|
||||
*
|
||||
* @param pos the pos
|
||||
* @return the leash state
|
||||
*/
|
||||
Optional<LeashState> getLeashState(BlockPos pos);
|
||||
|
||||
/**
|
||||
* Gets holder location offset.
|
||||
*
|
||||
* @param entity the entity
|
||||
* @return the holder location offset
|
||||
*/
|
||||
/* ----------------------
|
||||
* Get offsets
|
||||
* ---------------------- */
|
||||
Optional<Vec3> getHolderLocationOffset(Entity entity);
|
||||
|
||||
/**
|
||||
* Gets holder location offset.
|
||||
*
|
||||
* @param uuid the uuid
|
||||
* @return the holder location offset
|
||||
*/
|
||||
Optional<Vec3> getHolderLocationOffset(UUID uuid);
|
||||
|
||||
/**
|
||||
* Gets holder location offset.
|
||||
*
|
||||
* @param pos the pos
|
||||
* @return the holder location offset
|
||||
*/
|
||||
Optional<Vec3> getHolderLocationOffset(BlockPos pos);
|
||||
|
||||
/**
|
||||
* Gets leash apply entity location offset.
|
||||
*
|
||||
* @return the leash apply entity location offset
|
||||
*/
|
||||
Optional<Vec3> 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<CompoundTag> {
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> getMarks() {
|
||||
|
|
@ -336,6 +502,8 @@ public record LeashInfo(
|
|||
|
||||
/**
|
||||
* 清除所有标记
|
||||
*
|
||||
* @return the leash info
|
||||
*/
|
||||
public LeashInfo clearAllMarks() {
|
||||
if (marks.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -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<ILeashData> 持有的实体的拴绳数据能力集合}
|
||||
*/
|
||||
Set<ILeashData> getAllLeashData();
|
||||
Set<ILeashData> getAllLeash();
|
||||
|
||||
/**
|
||||
* 获取该实体持有的所有实体实例
|
||||
*
|
||||
* @return {@link Set<Entity> 持有的实体集合}
|
||||
*/
|
||||
default Set<Entity> getAllLeashedEntities() {
|
||||
return getAllLeash().stream().map(ILeashData::self).collect(Collectors.toSet());
|
||||
}
|
||||
/**
|
||||
* 获取该实体持有的指定实体实例
|
||||
*
|
||||
* @param clazz 实体类型
|
||||
* @param box 搜索范围
|
||||
* @param filter {@link Predicate<Entity> 实体过滤器}
|
||||
*
|
||||
* @return {@link Set<Entity> 持有的实体集合}
|
||||
*/
|
||||
default Set<Entity> getLeashEntities (Class<Entity> clazz, AABB box, Predicate<Entity> filter) {
|
||||
return getLeash(clazz, box, filter).stream().map(ILeashData::self).collect(Collectors.toSet());
|
||||
}
|
||||
/**
|
||||
* 获取该实体持有的符合条件实体的拴绳数据能力
|
||||
*
|
||||
* @param clazz 实体类型
|
||||
* @param box 搜索范围
|
||||
* @param filter {@link Predicate<Entity> 实体过滤器}
|
||||
*
|
||||
* @return {@link Set<ILeashData> 持有的实体的拴绳数据能力集合}
|
||||
*/
|
||||
Set<ILeashData> getLeash(Class<Entity> clazz, AABB box, Predicate<Entity> filter);
|
||||
|
||||
/**
|
||||
* 获取该实体持有的符合条件实体实例
|
||||
*
|
||||
* @param clazz 实体类型
|
||||
* @param fetchDistance 搜索范围(以实体为中心的正方体{@link AABB#ofSize(Vec3, double, double, double) 包围盒})
|
||||
* @param filter {@link Predicate<Entity> 实体过滤器}
|
||||
*
|
||||
* @return {@link Set<Entity> 持有的实体实例}
|
||||
*/
|
||||
default Set<Entity> getLeashEntities (Class<Entity> clazz, double fetchDistance, Predicate<Entity> 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<Entity> 实体过滤器}
|
||||
*
|
||||
* @return {@link Set<ILeashData> 持有的实体的拴绳数据能力集合}
|
||||
*/
|
||||
default Set<ILeashData> getLeash(Class<Entity> clazz, double fetchDistance, Predicate<Entity> filter) {
|
||||
return getLeash(clazz, AABB.ofSize(getHolderEntity().position(), fetchDistance, fetchDistance, fetchDistance), filter);
|
||||
}
|
||||
/**
|
||||
* 获取该实体持有的符合条件实体实例
|
||||
*
|
||||
* @param clazz 实体类型
|
||||
* @param filter {@link Predicate<Entity> 实体过滤器}
|
||||
*
|
||||
* @return {@link Set<Entity> 持有的实体实例}
|
||||
*/
|
||||
default Set<Entity> getLeashEntities (Class<Entity> clazz, Predicate<Entity> filter) {
|
||||
return getLeash(clazz, filter).stream().map(ILeashData::self).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取该实体持有的符合条件实体的拴绳数据能力
|
||||
*
|
||||
* @param clazz 实体类型
|
||||
* @param filter {@link Predicate<Entity> 实体过滤器}
|
||||
*
|
||||
* @return {@link Set<ILeashData> 持有的实体的拴绳数据能力集合}
|
||||
*/
|
||||
default Set<ILeashData> getLeash(Class<Entity> clazz, Predicate<Entity> filter) {
|
||||
return getLeash(clazz, 1024D, filter);
|
||||
}
|
||||
/**
|
||||
* 获取该实体持有的符合条件实体实例
|
||||
*
|
||||
* @param clazz 实体类型
|
||||
*
|
||||
* @return {@link Set<Entity> 持有的实体实例}
|
||||
*/
|
||||
default Set<Entity> getLeashEntities (Class<Entity> clazz) {
|
||||
return getLeash(clazz).stream().map(ILeashData::self).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取该实体持有的符合条件实体的拴绳数据能力
|
||||
*
|
||||
* @param clazz 实体类型
|
||||
*
|
||||
* @return {@link Set<ILeashData> 持有的实体的拴绳数据能力集合}
|
||||
*/
|
||||
default Set<ILeashData> getLeash(Class<Entity> 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<LeashInfo> getLeashInfo(Entity entity) {
|
||||
return getLeashData().getLeashInfo(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拴绳信息
|
||||
*
|
||||
* @param holderUUID the holder uuid
|
||||
* @return the leash info
|
||||
*/
|
||||
default Optional<LeashInfo> getLeashInfo(UUID holderUUID) {
|
||||
return getLeashData().getLeashInfo(holderUUID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拴绳信息
|
||||
*
|
||||
* @param knotPos the knot pos
|
||||
* @return the leash info
|
||||
*/
|
||||
default Optional<LeashInfo> 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<Boolean> cond, Supplier<Boolean> trueSupplier, Supplier<Boolean> 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<Boolean> cond, Supplier<Void> trueSupplier, Supplier<Void> falseSupplier) {
|
||||
if (cond.get()) {
|
||||
trueSupplier.get();
|
||||
|
|
|
|||
|
|
@ -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<Entity> leashableInArea(@NotNull Level pLevel, Vec3 pPos, Predicate<Entity> 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<Entity> leashableInArea(@NotNull Level pLevel, Class<Entity> clazz,Predicate<Entity> 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<ILeashData> getLeashData(@NotNull Entity pEntity);
|
||||
|
||||
/**
|
||||
* Gets leash state.
|
||||
*
|
||||
* @param pEntity the p entity
|
||||
* @return the leash state
|
||||
*/
|
||||
Optional<ILeashState> getLeashState(@NotNull Entity pEntity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <T> the type parameter
|
||||
* @param clazz the clazz
|
||||
* @return the t
|
||||
*/
|
||||
public static <T> T load(Class<T> clazz) {
|
||||
final T loadedService = ServiceLoader.load(clazz)
|
||||
.findFirst()
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 <T> the type parameter
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class SuperLeashKnotModel<T extends Entity> extends HierarchicalModel<T> {
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<SuperLeashKnotEntity> {
|
||||
private static final ResourceLocation KNOT_LOCATION = new ResourceLocation(SuperLeadRope.MOD_ID, "textures/entity/super_lead_knot.png");
|
||||
private final SuperLeashKnotModel<SuperLeashKnotEntity> 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));
|
||||
|
|
|
|||
|
|
@ -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<SuperLeashRenderState> 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) {
|
||||
// 从眼睛位置(头部)开始
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
// 基于正弦波的摆动效果
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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<String> SLPModCommandPrefix;
|
||||
|
||||
// Entity
|
||||
/**
|
||||
* The Teleport whitelist.
|
||||
*/
|
||||
// Entity
|
||||
public final ForgeConfigSpec.ConfigValue<List<? extends String>> 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<List<? extends Double>> 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<List<? extends String>> defaultApplyEntityLocationOffset;
|
||||
/**
|
||||
* The Default holder location offset.
|
||||
*/
|
||||
public final ForgeConfigSpec.ConfigValue<List<? extends String>> 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");
|
||||
|
|
|
|||
|
|
@ -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<Double> MAX_DISTANCE_CHECK = distance -> distance == null || (distance >= 6.0 && distance <= 256.0);
|
||||
/**
|
||||
* The constant ELASTIC_DISTANCE_CHECK.
|
||||
*/
|
||||
public static final Predicate<Double> ELASTIC_DISTANCE_CHECK = distance -> distance == null || (distance >= 0.2 && distance <= 4.0);
|
||||
// ========== 偏移映射 ==========
|
||||
private final Map<String, double[]> entityHolderMap = new ConcurrentHashMap<>();
|
||||
|
|
@ -60,6 +69,9 @@ public class LeashConfigManager {
|
|||
private volatile List<Double> 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<String, Map<String, double[]>> 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<String> 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<Double> 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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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<Item> LEAD = tag("lead");
|
||||
private static TagKey<net.minecraft.world.item.Item> tag(String name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<IEternalPotato> 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 &&
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -104,6 +104,11 @@ public class LeashDataImpl implements ILeashData {
|
|||
// 引入解决 绳结不保存导致第二进入持有者不存在的问题
|
||||
private final Map<BlockPos, LeashInfo> 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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<CompoundTag> {
|
||||
|
||||
/**
|
||||
* 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<CompoundTa
|
|||
// 新增引用 ItemStack
|
||||
private final ItemStack stack;
|
||||
|
||||
/**
|
||||
* Instantiates a new Eternal potato provider.
|
||||
*
|
||||
* @param stack the stack
|
||||
*/
|
||||
public EternalPotatoProvider(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
this.uuid = EternalPotatoItem.getOrCreateItemUUID(stack);
|
||||
|
|
|
|||
|
|
@ -29,10 +29,22 @@ import top.r3944realms.superleadrope.api.SLPCapability;
|
|||
import top.r3944realms.superleadrope.api.type.capabilty.ILeashData;
|
||||
import top.r3944realms.superleadrope.content.capability.impi.LeashDataImpl;
|
||||
|
||||
/**
|
||||
* The type Leash data provider.
|
||||
*/
|
||||
public class LeashDataProvider implements ICapabilitySerializable<CompoundTag> {
|
||||
/**
|
||||
* 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<ILeashData> 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);
|
||||
|
|
|
|||
|
|
@ -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<CompoundTag> {
|
||||
/**
|
||||
* 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<ILeashState> 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);
|
||||
|
|
|
|||
|
|
@ -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<CommandSourceStack> getLiterArgumentBuilderOfCSS(String name, boolean shouldAddToList, @Nullable List<LiteralArgumentBuilder<CommandSourceStack>> list) {
|
||||
LiteralArgumentBuilder<CommandSourceStack> literal = Commands.literal(name);
|
||||
if (shouldAddToList) {
|
||||
|
|
|
|||
|
|
@ -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<CommandSourceStack> dispatcher) {
|
||||
@Nullable List<LiteralArgumentBuilder<CommandSourceStack>> nodeList = SHOULD_USE_PREFIX ? null : new ArrayList<>();
|
||||
LiteralArgumentBuilder<CommandSourceStack> 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<CommandSourceStack> 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<CommandSourceStack> 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<CommandSourceStack> 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<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
return transferFromBlock(context, "");
|
||||
|
|
@ -313,6 +369,10 @@ public class LeashDataCommand {
|
|||
private static int transferFromBlock(CommandContext<CommandSourceStack> 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<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
return setElasticDistance(context, 0 ,"");
|
||||
|
|
@ -323,6 +383,10 @@ public class LeashDataCommand {
|
|||
private static int setElasticDistance(CommandContext<CommandSourceStack> 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<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
return setBlockMaxDistance(context, 0 ,"");
|
||||
|
|
@ -333,6 +397,10 @@ public class LeashDataCommand {
|
|||
private static int setBlockMaxDistance(CommandContext<CommandSourceStack> 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<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
return setBlockElasticDistance(context, 0 ,"");
|
||||
|
|
|
|||
|
|
@ -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
|
||||
// <addApplyEntity/setApplyEntity/reset> Holder<BlockPos/Entity<需判断实体类型>> <Holder/Entity> <x> <y> <z>
|
||||
// 设置对应目标的 拴绳偏移
|
||||
|
|
|
|||
|
|
@ -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<CommandSourceStack> dispatcher) {
|
||||
@Nullable List<LiteralArgumentBuilder<CommandSourceStack>> nodeList = SHOULD_USE_PREFIX ? null : new ArrayList<>();
|
||||
LiteralArgumentBuilder<CommandSourceStack> literalArgumentBuilder = Commands.literal(PREFIX);
|
||||
|
|
|
|||
|
|
@ -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<SuperLeashKnotEntity> 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<Block> tagKey : SUPPORTED_BLOCK) {
|
||||
if(state.is(tagKey)) {
|
||||
|
|
|
|||
|
|
@ -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<String, Boolean> gamerulesBooleanValuesClient = new HashMap<>();
|
||||
/**
|
||||
* The constant gameruleIntegerValuesClient.
|
||||
*/
|
||||
public static final HashMap<String, Integer> 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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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<ILeashData> LEASH_DATA = Collections.newSetFromMap(new WeakHashMap<>());
|
||||
/**
|
||||
* The Leash states.
|
||||
*/
|
||||
static final Set<ILeashState> 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<ILeashData> 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<ILeashState> consumer) {
|
||||
LEASH_STATES.forEach(consumer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,31 +36,67 @@ public class EternalPotatoFacade {
|
|||
private static PotatoSavedData savedData;
|
||||
// 全局监听器
|
||||
private static final List<IEternalPotatoChangeListener> 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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -34,6 +34,12 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
class SyncedEternalPotatoManager implements IEternalPotatoManager {
|
||||
private final Map<UUID, EternalPotatoImpl> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<UUID, Integer> countdownMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* On server tick.
|
||||
*/
|
||||
public static void onServerTick() {
|
||||
|
||||
var server = ServerLifecycleHooks.getCurrentServer();
|
||||
|
|
|
|||
|
|
@ -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<String, IObligationCompletion> 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
|
||||
}
|
||||
|
||||
/**
|
||||
* 一个便捷的静态空实现(默认永不完成)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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<EntityType<?>> ENTITY_TYPES =
|
||||
DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, SuperLeadRope.MOD_ID);
|
||||
/**
|
||||
* The Super lead knot.
|
||||
*/
|
||||
public static RegistryObject<EntityType<SuperLeashKnotEntity>> SUPER_LEAD_KNOT = ENTITY_TYPES.register(
|
||||
"super_lead_knot",
|
||||
() -> EntityType.Builder.<SuperLeashKnotEntity>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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<String, GameRules.Key<?>> gamerules = new HashMap<>();;
|
||||
/**
|
||||
* The constant gameruleDataTypes.
|
||||
*/
|
||||
public static final Map<String, RuleDataType> 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.BooleanValue>) 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.IntegerValue>)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<MinecraftServer, GameRules.BooleanValue> 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<MinecraftServer, GameRules.IntegerValue> 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();
|
||||
|
|
|
|||
|
|
@ -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<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, SuperLeadRope.MOD_ID);
|
||||
/**
|
||||
* The constant SUPER_LEAD_ROPE.
|
||||
*/
|
||||
public static final RegistryObject<Item> SUPER_LEAD_ROPE = ITEMS.register(
|
||||
"super_lead_rope",
|
||||
() -> new SuperLeadRopeItem(new Item.Properties())
|
||||
);
|
||||
/**
|
||||
* The constant ETERNAL_POTATO.
|
||||
*/
|
||||
public static final RegistryObject<Item> 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<String, IObligationCompletion> getAll() {
|
||||
return Collections.unmodifiableMap(REGISTRY);
|
||||
|
|
|
|||
|
|
@ -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<SoundEvent> 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<SoundEvent> LEAD_UNTIED = registerSound("lead_untied");
|
||||
/**
|
||||
* The constant LEAD_TIED.
|
||||
*/
|
||||
public static final RegistryObject<SoundEvent> LEAD_TIED = registerSound("lead_tied");
|
||||
/**
|
||||
* The constant LEAD_BREAK.
|
||||
*/
|
||||
public static final RegistryObject<SoundEvent> LEAD_BREAK = registerSound("lead_break");
|
||||
private static RegistryObject<SoundEvent> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,23 @@ package top.r3944realms.superleadrope.core.util;
|
|||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* The type Immutable pair.
|
||||
*
|
||||
* @param <F> the type parameter
|
||||
* @param <S> the type parameter
|
||||
*/
|
||||
public record ImmutablePair<F, S>(F first, S second) {
|
||||
|
||||
/**
|
||||
* Of immutable pair.
|
||||
*
|
||||
* @param <F> the type parameter
|
||||
* @param <S> the type parameter
|
||||
* @param first the first
|
||||
* @param second the second
|
||||
* @return the immutable pair
|
||||
*/
|
||||
public static <F, S> ImmutablePair<F, S> of(F first, S second) {
|
||||
return new ImmutablePair<>(first, second);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<HolderLookup.Provider> lookupProvider,
|
||||
|
|
|
|||
|
|
@ -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<Item> 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<HolderLookup.Provider> holderProvider,
|
||||
|
|
|
|||
|
|
@ -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<String, String> LanKeyMap;
|
||||
private static final List<String> 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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <MSG> the type parameter
|
||||
* @param message the message
|
||||
* @param player the player
|
||||
*/
|
||||
public static <MSG> void sendToPlayer(MSG message, ServerPlayer player){
|
||||
INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send to player.
|
||||
*
|
||||
* @param <MSG> the type parameter
|
||||
* @param <T> the type parameter
|
||||
* @param message the message
|
||||
* @param entity the entity
|
||||
* @param packetDistributor the packet distributor
|
||||
*/
|
||||
public static <MSG, T> void sendToPlayer(MSG message, T entity, PacketDistributor<T> packetDistributor){
|
||||
INSTANCE.send(packetDistributor.with(() -> entity), message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
// 获取全局能力实例
|
||||
|
|
|
|||
|
|
@ -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<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
ClientLevel level = Minecraft.getInstance().level;
|
||||
|
|
|
|||
|
|
@ -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<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
ClientLevel level = Minecraft.getInstance().level;
|
||||
|
|
|
|||
|
|
@ -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<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
// 客户端收到移除请求
|
||||
|
|
|
|||
|
|
@ -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<NetworkEvent.Context> 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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<ILeashData> 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<LeashInfo> 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<LeashInfo> 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<LeashInfo> 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<LeashInfo> 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<UUID> 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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<ILeashState> 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<UUID, ILeashState.LeashState> 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<BlockPos, ILeashState.LeashState> 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<ILeashState.LeashState> 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<ILeashState.LeashState> 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<ILeashState.LeashState> 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<Vec3> 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 ->
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user