Compare commits
No commits in common. "master" and "1.0-SNAPSHOT" have entirely different histories.
master
...
1.0-SNAPSH
|
@ -1 +1 @@
|
||||||
vmodextras
|
vmodaddon
|
|
@ -1,7 +0,0 @@
|
||||||
<component name="ProjectCodeStyleConfiguration">
|
|
||||||
<code_scheme name="Project" version="173">
|
|
||||||
<ScalaCodeStyleSettings>
|
|
||||||
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
|
||||||
</ScalaCodeStyleSettings>
|
|
||||||
</code_scheme>
|
|
||||||
</component>
|
|
|
@ -1,5 +0,0 @@
|
||||||
<component name="ProjectCodeStyleConfiguration">
|
|
||||||
<state>
|
|
||||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
|
||||||
</state>
|
|
||||||
</component>
|
|
|
@ -5,11 +5,10 @@
|
||||||
<profile name="Gradle Imported" enabled="true">
|
<profile name="Gradle Imported" enabled="true">
|
||||||
<outputRelativeToContentRoot value="true" />
|
<outputRelativeToContentRoot value="true" />
|
||||||
<processorPath useClasspath="false">
|
<processorPath useClasspath="false">
|
||||||
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/io.github.llamalad7/mixinextras-common/0.4.1/a7f425cc49de7f10d008a9a676f5f023ebac13bb/mixinextras-common-0.4.1.jar" />
|
|
||||||
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.spongepowered/mixin/0.8.5/6d1c8bf4c28e697f472a83bd6add76ec4951734/mixin-0.8.5-processor.jar" />
|
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.spongepowered/mixin/0.8.5/6d1c8bf4c28e697f472a83bd6add76ec4951734/mixin-0.8.5-processor.jar" />
|
||||||
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.18.20/18bcea7d5df4d49227b4a0743a536208ce4825bb/lombok-1.18.20.jar" />
|
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.18.20/18bcea7d5df4d49227b4a0743a536208ce4825bb/lombok-1.18.20.jar" />
|
||||||
</processorPath>
|
</processorPath>
|
||||||
<module name="vmodextras.main" />
|
<module name="vmodaddon.main" />
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
<bytecodeTargetLevel target="17" />
|
<bytecodeTargetLevel target="17" />
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="DiscordProjectSettings">
|
|
||||||
<option name="show" value="PROJECT_FILES" />
|
|
||||||
<option name="description" value="" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="io.github.pandier.intellijdiscordrp.settings.project.DiscordProjectSettingsComponent">
|
|
||||||
<option name="displayMode" value="File" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -5,7 +5,6 @@
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="ms-17" />
|
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|
|
@ -26,40 +26,5 @@
|
||||||
<option name="name" value="MavenRepo" />
|
<option name="name" value="MavenRepo" />
|
||||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="Modrinth" />
|
|
||||||
<option name="name" value="Modrinth" />
|
|
||||||
<option name="url" value="https://api.modrinth.com/maven" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="maven" />
|
|
||||||
<option name="name" value="maven" />
|
|
||||||
<option name="url" value="https://maven.tterrag.com/releases" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="maven2" />
|
|
||||||
<option name="name" value="maven2" />
|
|
||||||
<option name="url" value="https://squiddev.cc/maven/" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="maven3" />
|
|
||||||
<option name="name" value="maven3" />
|
|
||||||
<option name="url" value="https://cursemaven.com" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="tterrag maven" />
|
|
||||||
<option name="name" value="tterrag maven" />
|
|
||||||
<option name="url" value="https://maven.tterrag.com/" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="maven4" />
|
|
||||||
<option name="name" value="maven4" />
|
|
||||||
<option name="url" value="https://maven.minecraftforge.net" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="maven5" />
|
|
||||||
<option name="name" value="maven5" />
|
|
||||||
<option name="url" value="https://maven.bawnorton.com/releases" />
|
|
||||||
</remote-repository>
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -1,10 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="EntryPointsManager">
|
|
||||||
<writeAnnotations>
|
|
||||||
<writeAnnotation name="org.spongepowered.asm.mixin.Unique" />
|
|
||||||
</writeAnnotations>
|
|
||||||
</component>
|
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="ms-17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="ms-17" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/vmodextras.main.iml" filepath="$PROJECT_DIR$/.idea/modules/vmodextras.main.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/modules/vmodaddon.main.iml" filepath="$PROJECT_DIR$/.idea/modules/vmodaddon.main.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/vmodextras.test.iml" filepath="$PROJECT_DIR$/.idea/modules/vmodextras.test.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/modules/vmodaddon.test.iml" filepath="$PROJECT_DIR$/.idea/modules/vmodaddon.test.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
2
.idea/modules/vmodextras.main.iml → .idea/modules/vmodaddon.main.iml
Executable file → Normal file
2
.idea/modules/vmodextras.main.iml → .idea/modules/vmodaddon.main.iml
Executable file → Normal file
|
@ -21,7 +21,7 @@
|
||||||
<option name="mappingFile" value="$MODULE_DIR$/../../build/createMcpToSrg/output.tsrg" />
|
<option name="mappingFile" value="$MODULE_DIR$/../../build/createMcpToSrg/output.tsrg" />
|
||||||
<option name="mcpVersion" value="official_1.20.1" />
|
<option name="mcpVersion" value="official_1.20.1" />
|
||||||
<option name="minecraftVersion" value="1.20.1" />
|
<option name="minecraftVersion" value="1.20.1" />
|
||||||
<option name="platformVersion" value="47.3.5" />
|
<option name="platformVersion" value="47.4.1" />
|
||||||
<option name="srgType" value="TSRG" />
|
<option name="srgType" value="TSRG" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
2
.idea/modules/io.p2vman.vmodextras.test.iml → .idea/modules/vmodaddon.test.iml
Executable file → Normal file
2
.idea/modules/io.p2vman.vmodextras.test.iml → .idea/modules/vmodaddon.test.iml
Executable file → Normal file
|
@ -16,7 +16,7 @@
|
||||||
<option name="mappingFile" value="$MODULE_DIR$/../../build/createMcpToSrg/output.tsrg" />
|
<option name="mappingFile" value="$MODULE_DIR$/../../build/createMcpToSrg/output.tsrg" />
|
||||||
<option name="mcpVersion" value="official_1.20.1" />
|
<option name="mcpVersion" value="official_1.20.1" />
|
||||||
<option name="minecraftVersion" value="1.20.1" />
|
<option name="minecraftVersion" value="1.20.1" />
|
||||||
<option name="platformVersion" value="47.3.5" />
|
<option name="platformVersion" value="47.4.1" />
|
||||||
<option name="srgType" value="TSRG" />
|
<option name="srgType" value="TSRG" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -1,22 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module version="4">
|
|
||||||
<component name="FacetManager">
|
|
||||||
<facet type="minecraft" name="Minecraft">
|
|
||||||
<configuration>
|
|
||||||
<autoDetectTypes>
|
|
||||||
<platformType>FORGE</platformType>
|
|
||||||
<platformType>MIXIN</platformType>
|
|
||||||
<platformType>MCP</platformType>
|
|
||||||
</autoDetectTypes>
|
|
||||||
<projectReimportVersion>1</projectReimportVersion>
|
|
||||||
</configuration>
|
|
||||||
</facet>
|
|
||||||
</component>
|
|
||||||
<component name="McpModuleSettings">
|
|
||||||
<option name="mappingFile" value="$MODULE_DIR$/../../build/createMcpToSrg/output.tsrg" />
|
|
||||||
<option name="mcpVersion" value="official_1.20.1" />
|
|
||||||
<option name="minecraftVersion" value="1.20.1" />
|
|
||||||
<option name="platformVersion" value="47.3.5" />
|
|
||||||
<option name="srgType" value="TSRG" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
|
@ -140,36 +140,6 @@ repositories {
|
||||||
// flatDir {
|
// flatDir {
|
||||||
// dir 'libs'
|
// dir 'libs'
|
||||||
// }
|
// }
|
||||||
|
|
||||||
flatDir {
|
|
||||||
dirs("libs")
|
|
||||||
}
|
|
||||||
|
|
||||||
maven {
|
|
||||||
name = "Modrinth"
|
|
||||||
url = uri("https://api.modrinth.com/maven")
|
|
||||||
}
|
|
||||||
|
|
||||||
maven {
|
|
||||||
url = uri("https://maven.tterrag.com/releases")
|
|
||||||
}
|
|
||||||
|
|
||||||
maven { url 'https://squiddev.cc/maven/' }
|
|
||||||
|
|
||||||
maven {
|
|
||||||
url "https://cursemaven.com"
|
|
||||||
content {
|
|
||||||
includeGroup "curse.maven"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
maven { url = 'https://maven.minecraftforge.net' }
|
|
||||||
maven {
|
|
||||||
name = 'tterrag maven'
|
|
||||||
url = 'https://maven.tterrag.com/'
|
|
||||||
}
|
|
||||||
|
|
||||||
maven { url = "https://maven.bawnorton.com/releases" }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -191,49 +161,9 @@ dependencies {
|
||||||
// The group id is ignored when searching -- in this case, it is "blank"
|
// The group id is ignored when searching -- in this case, it is "blank"
|
||||||
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
|
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
|
||||||
|
|
||||||
implementation fg.deobf(files("./libs/vmod-forge-1.20.1-1.2.2.jar"))
|
implementation fg.deobf(files("./libs/VMod-Forge-1.20.1-1.2.2.jar"))
|
||||||
implementation fg.deobf(files("./libs/valkyrien-ship-schematics-forge-1.20.1-1.1.jar"))
|
implementation fg.deobf(files("./libs/valkyrien-ship-schematics-forge-1.20.1-1.1.jar"))
|
||||||
implementation(fg.deobf(files("./libs/kotlinforforge-4.11.0-all.jar")))
|
implementation fg.deobf(files("./libs/kotlinforforge-4.11.0-all.jar"))
|
||||||
implementation(fg.deobf(files("./libs/trackwork-1.20.1-1.1.1b.jar")))
|
|
||||||
implementation(fg.deobf("org.valkyrienskies:valkyrienskies-120:2.3.0-beta.7"))
|
|
||||||
|
|
||||||
implementation("org.joml:joml:1.10.4") { transitive = false }
|
|
||||||
implementation("org.joml:joml-primitives:1.10.0") { transitive = false }
|
|
||||||
|
|
||||||
implementation fg.deobf("curse.maven:create-tweaked-controllers-898849:5206625")
|
|
||||||
|
|
||||||
//compileOnly(annotationProcessor("com.bawnorton.mixinsquared:mixinsquared-common:0.2.0-beta.6"))
|
|
||||||
//implementation(jarJar("com.bawnorton.mixinsquared:mixinsquared-forge:0.2.0-beta.6")) {
|
|
||||||
// jarJar.ranged(it, "[0.2.0-beta.6,)")
|
|
||||||
//}
|
|
||||||
|
|
||||||
implementation fg.deobf("libs:clockworkadditions:1.20.1-0.0.6")
|
|
||||||
|
|
||||||
|
|
||||||
implementation(files("./libs/cobalt-0.9.3.jar"))
|
|
||||||
|
|
||||||
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.14.0'
|
|
||||||
|
|
||||||
implementation 'net.minecraftforge:modlauncher:10.1.1'
|
|
||||||
implementation 'net.minecraftforge:forgespi:7.1.0'
|
|
||||||
|
|
||||||
compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:0.4.1"))
|
|
||||||
implementation(jarJar("io.github.llamalad7:mixinextras-forge:0.4.1")) {
|
|
||||||
jarJar.ranged(it, "[0.4.1,)")
|
|
||||||
}
|
|
||||||
|
|
||||||
implementation fg.deobf("libs:cc-tweaked:1.20.1-forge-1.113.1")
|
|
||||||
|
|
||||||
|
|
||||||
implementation fg.deobf("libs:drivebywire:1.20.1-0.0.10")
|
|
||||||
implementation(fg.deobf("com.simibubi.create:create-1.20.1:0.5.1.j"))
|
|
||||||
implementation fg.deobf(files("./libs/api-1.1.0+b19b27c4a4.jar"))
|
|
||||||
|
|
||||||
implementation fg.deobf(files("./libs/WariumVS 0.0.4.jar"))
|
|
||||||
|
|
||||||
//implementation fg.deobf("maven.modrinth:create-copies-cats:0.0.1-1.20.1")
|
|
||||||
//implementation fg.deobf(files("./libs/framed/FramedBlocks-9.3.0.jar"))
|
|
||||||
|
|
||||||
|
|
||||||
// For more info:
|
// For more info:
|
||||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||||
|
@ -243,9 +173,6 @@ dependencies {
|
||||||
compileOnly 'org.projectlombok:lombok:1.18.20'
|
compileOnly 'org.projectlombok:lombok:1.18.20'
|
||||||
annotationProcessor 'org.projectlombok:lombok:1.18.20'
|
annotationProcessor 'org.projectlombok:lombok:1.18.20'
|
||||||
|
|
||||||
//implementation fg.deobf("org.squiddev:cc-tweaked-1.19.2:1.101.3")
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -258,7 +185,7 @@ tasks.named('processResources', ProcessResources).configure {
|
||||||
forge_version : forge_version, forge_version_range: forge_version_range,
|
forge_version : forge_version, forge_version_range: forge_version_range,
|
||||||
loader_version_range: loader_version_range,
|
loader_version_range: loader_version_range,
|
||||||
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
|
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
|
||||||
mod_authors : mod_authors, mod_description: mod_description,the_vmod_version:the_vmod_version,valkyrien_ship_schematics_version:valkyrien_ship_schematics_version,]
|
mod_authors : mod_authors, mod_description: mod_description,]
|
||||||
|
|
||||||
inputs.properties replaceProperties
|
inputs.properties replaceProperties
|
||||||
|
|
||||||
|
@ -276,9 +203,7 @@ tasks.named('jar', Jar).configure {
|
||||||
"Implementation-Title" : project.name,
|
"Implementation-Title" : project.name,
|
||||||
"Implementation-Version" : project.jar.archiveVersion,
|
"Implementation-Version" : project.jar.archiveVersion,
|
||||||
"Implementation-Vendor" : mod_authors,
|
"Implementation-Vendor" : mod_authors,
|
||||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")])
|
||||||
"Main-Class" : "io.p2vman.vmodextras.main.Main"
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the preferred method to reobfuscate your jar file
|
// This is the preferred method to reobfuscate your jar file
|
||||||
|
|
|
@ -1,19 +1,49 @@
|
||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
|
# The Minecraft version must agree with the Forge version to get a valid artifact
|
||||||
minecraft_version=1.20.1
|
minecraft_version=1.20.1
|
||||||
|
# The Minecraft version range can use any release version of Minecraft as bounds.
|
||||||
|
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
|
||||||
|
# as they do not follow standard versioning conventions.
|
||||||
minecraft_version_range=[1.20.1,1.21)
|
minecraft_version_range=[1.20.1,1.21)
|
||||||
forge_version=47.3.5
|
# The Forge version must agree with the Minecraft version to get a valid artifact
|
||||||
|
forge_version=47.4.1
|
||||||
|
# The Forge version range can use any version of Forge as bounds or match the loader version range
|
||||||
forge_version_range=[47,)
|
forge_version_range=[47,)
|
||||||
|
# The loader version range can only use the major version of Forge/FML as bounds
|
||||||
loader_version_range=[47,)
|
loader_version_range=[47,)
|
||||||
|
# The mapping channel to use for mappings.
|
||||||
|
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
|
||||||
|
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
|
||||||
|
#
|
||||||
|
# | Channel | Version | |
|
||||||
|
# |-----------|----------------------|--------------------------------------------------------------------------------|
|
||||||
|
# | official | MCVersion | Official field/method names from Mojang mapping files |
|
||||||
|
# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official |
|
||||||
|
#
|
||||||
|
# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
|
||||||
|
# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
|
||||||
|
#
|
||||||
|
# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge.
|
||||||
|
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
|
||||||
mapping_channel=official
|
mapping_channel=official
|
||||||
|
# The mapping version to query from the mapping channel.
|
||||||
|
# This must match the format required by the mapping channel.
|
||||||
mapping_version=1.20.1
|
mapping_version=1.20.1
|
||||||
mod_id=vmodextras
|
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
|
||||||
mod_name=VModExtras
|
# Must match the String constant located in the main mod class annotated with @Mod.
|
||||||
|
mod_id=vmodaddon
|
||||||
|
# The human-readable display name for the mod.
|
||||||
|
mod_name=VModAddon
|
||||||
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=MIT
|
mod_license=MIT
|
||||||
mod_version=0.0.2b
|
# The mod version. See https://semver.org/
|
||||||
mod_group_id=io.p2vman
|
mod_version=1.0-SNAPSHOT
|
||||||
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
|
# This should match the base package used for the mod sources.
|
||||||
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
mod_group_id=space.eptaproject
|
||||||
|
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
|
||||||
mod_authors=p2vman
|
mod_authors=p2vman
|
||||||
|
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
||||||
mod_description=
|
mod_description=
|
||||||
|
|
||||||
the_vmod_version = 1.2.2
|
|
||||||
valkyrien_ship_schematics_version = 1.0
|
|
7
license
7
license
|
@ -1,7 +0,0 @@
|
||||||
Copyright 2025 p2vman
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
@ -12,4 +12,4 @@ plugins {
|
||||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
|
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
rootProject.name = 'vmodextras'
|
rootProject.name = 'vmodaddon'
|
||||||
|
|
|
@ -1,166 +0,0 @@
|
||||||
package io.p2vman.vmodextras;
|
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectImmutableList;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.util.Mth;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class Config {
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public static class ClampContext {
|
|
||||||
private boolean enable;
|
|
||||||
private double min;
|
|
||||||
private double max;
|
|
||||||
|
|
||||||
private ForgeConfigSpec.ConfigValue<Double> _min;
|
|
||||||
private ForgeConfigSpec.ConfigValue<Double> _max;
|
|
||||||
private ForgeConfigSpec.ConfigValue<Boolean> _enable;
|
|
||||||
|
|
||||||
public double clamp(double input) {
|
|
||||||
if (!enable) return input;
|
|
||||||
return Math.max(Math.min(input, max), min);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update() {
|
|
||||||
enable = _enable.get();
|
|
||||||
max = _max.get();
|
|
||||||
min = _min.get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static final ForgeConfigSpec COMMON_CONFIG;
|
|
||||||
public static final ForgeConfigSpec.ConfigValue<List<? extends String>> RESOURCE_LOCATION_LIST;
|
|
||||||
public static final ForgeConfigSpec.ConfigValue<List<? extends String>> ITEM_BLACK_LIST;
|
|
||||||
public static final ForgeConfigSpec.ConfigValue<String> RESOURCE_LOCATION;
|
|
||||||
|
|
||||||
public static final ForgeConfigSpec.ConfigValue<Integer> Suspension_Stiffness_LIMIT;
|
|
||||||
public static final ForgeConfigSpec.ConfigValue<Double> Suspension_Stiffness_delta;
|
|
||||||
|
|
||||||
public static final ForgeConfigSpec.ConfigValue<Boolean> Schematic_Blocked_Blocks;
|
|
||||||
public static final ForgeConfigSpec.ConfigValue<Boolean> Inventory_Blocked_Blocks;
|
|
||||||
|
|
||||||
public static List<ResourceLocation> parsedList = new ObjectArrayList<>();
|
|
||||||
private static List<Map.Entry<Integer, ResourceLocation>> ITEM = new ObjectImmutableList<>(new ArrayList<>());
|
|
||||||
public static ResourceLocation replace = Validator.RB;
|
|
||||||
public static boolean Inventory_Blocked_Blocks_Enable = false;
|
|
||||||
public static boolean Schematic_Blocked_Blocks_Enable = false;
|
|
||||||
public static ClampContext SCALE_CLAMP;
|
|
||||||
|
|
||||||
static {
|
|
||||||
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
|
||||||
|
|
||||||
builder.push("ToolGun");
|
|
||||||
|
|
||||||
builder.push("scale_clamp");
|
|
||||||
SCALE_CLAMP = new ClampContext(false, 0, 0,
|
|
||||||
builder.defineInRange("min", 0.3d, 0.001d, 30d),
|
|
||||||
builder.defineInRange("max", 1.5d, 0.001d, 30d),
|
|
||||||
builder.define("enable", true)
|
|
||||||
);
|
|
||||||
builder.pop();
|
|
||||||
|
|
||||||
builder.pop();
|
|
||||||
|
|
||||||
builder.push("Schematic");
|
|
||||||
|
|
||||||
RESOURCE_LOCATION_LIST = builder
|
|
||||||
.comment("List of blocked blocks, format: 'modid:path'")
|
|
||||||
.defineListAllowEmpty(
|
|
||||||
"blocked",
|
|
||||||
List.of("minecraft:stone", "minecraft:diamond_block"),
|
|
||||||
obj -> obj instanceof String && ResourceLocation.isValidResourceLocation((String) obj)
|
|
||||||
);
|
|
||||||
|
|
||||||
RESOURCE_LOCATION = builder
|
|
||||||
.comment("replace to, format: 'modid:path'")
|
|
||||||
.define(
|
|
||||||
"replace",
|
|
||||||
Validator.RB.toString()
|
|
||||||
);
|
|
||||||
|
|
||||||
Schematic_Blocked_Blocks = builder
|
|
||||||
.define("enable", false);
|
|
||||||
|
|
||||||
|
|
||||||
builder.pop();
|
|
||||||
|
|
||||||
builder.push("Inventory");
|
|
||||||
|
|
||||||
ITEM_BLACK_LIST = builder
|
|
||||||
.comment("List of blocked items, format: 'modid:path'")
|
|
||||||
.defineListAllowEmpty(
|
|
||||||
"blocked",
|
|
||||||
List.of("minecraft:stone", "minecraft:diamond_block"),
|
|
||||||
obj -> obj instanceof String && ResourceLocation.isValidResourceLocation((String) obj)
|
|
||||||
);
|
|
||||||
|
|
||||||
Inventory_Blocked_Blocks = builder
|
|
||||||
.define("enable", false);
|
|
||||||
|
|
||||||
builder.pop();
|
|
||||||
|
|
||||||
builder.push("TrackWork");
|
|
||||||
|
|
||||||
Suspension_Stiffness_LIMIT = builder
|
|
||||||
.comment("track suspension stiffness")
|
|
||||||
.defineInRange("SuspensionStiffness", 4, 1, 20);
|
|
||||||
|
|
||||||
Suspension_Stiffness_delta = builder
|
|
||||||
.comment("track suspension stiffness delta")
|
|
||||||
.defineInRange("suspension_stiffness_delta", 1d, 0.10d, 1d);
|
|
||||||
|
|
||||||
|
|
||||||
builder.pop();
|
|
||||||
COMMON_CONFIG = builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void bake() {
|
|
||||||
parsedList = RESOURCE_LOCATION_LIST.get().stream()
|
|
||||||
.map(ResourceLocation::tryParse)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
ITEM = new ObjectImmutableList(ITEM_BLACK_LIST.get().stream()
|
|
||||||
.map(s -> {
|
|
||||||
try {
|
|
||||||
ResourceLocation location = ResourceLocation.tryParse(s);
|
|
||||||
return new AbstractMap.SimpleEntry<Integer, ResourceLocation>(location.hashCode(), location);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.toList());
|
|
||||||
try {
|
|
||||||
replace = new ResourceLocation(RESOURCE_LOCATION.get());
|
|
||||||
} catch (Exception e) {
|
|
||||||
replace = Validator.RB;
|
|
||||||
}
|
|
||||||
|
|
||||||
Inventory_Blocked_Blocks_Enable = Inventory_Blocked_Blocks.get();
|
|
||||||
Schematic_Blocked_Blocks_Enable = Schematic_Blocked_Blocks.get();
|
|
||||||
|
|
||||||
SCALE_CLAMP.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean contains(ItemStack stack) {
|
|
||||||
if (stack.isEmpty() || !Inventory_Blocked_Blocks_Enable) return false;
|
|
||||||
ResourceLocation id = ForgeRegistries.ITEMS.getKey(stack.getItem());
|
|
||||||
if (id == null) return false;
|
|
||||||
|
|
||||||
int hash = id.hashCode();
|
|
||||||
for (var entry : ITEM) {
|
|
||||||
if (entry.getKey() == hash && entry.getValue().equals(id)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package io.p2vman.vmodextras;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.GameRules;
|
|
||||||
|
|
||||||
public class GameRulesBlat {
|
|
||||||
public static final GameRules.Key<GameRules.BooleanValue> EX4 =
|
|
||||||
GameRules.register("vmodextras_ex4", GameRules.Category.PLAYER, GameRules.BooleanValue.create(true));
|
|
||||||
|
|
||||||
|
|
||||||
public static void init() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,139 +0,0 @@
|
||||||
package io.p2vman.vmodextras;
|
|
||||||
|
|
||||||
import com.google.common.base.VerifyException;
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import com.mojang.logging.LogUtils;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.Font;
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.client.event.RenderGuiOverlayEvent;
|
|
||||||
import net.minecraftforge.client.event.RenderTooltipEvent;
|
|
||||||
import net.minecraftforge.client.gui.overlay.VanillaGuiOverlay;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
|
||||||
import net.minecraftforge.fml.ModLoadingException;
|
|
||||||
import net.minecraftforge.fml.ModLoadingStage;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.minecraftforge.fml.config.ModConfig;
|
|
||||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
|
||||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import io.p2vman.vmodextras.compact.Compact;
|
|
||||||
import io.p2vman.vmodextras.util.ModRegistry;
|
|
||||||
|
|
||||||
@Mod(VmodExtras.MODID)
|
|
||||||
public class VmodExtras {
|
|
||||||
public static final String MODID = "vmodextras";
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
|
||||||
|
|
||||||
public static final ModRegistry REGISTRY;
|
|
||||||
|
|
||||||
static {
|
|
||||||
REGISTRY = new ModRegistry(MODID);
|
|
||||||
|
|
||||||
new Compact((registry, builder) -> {
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String MIN_FORGE_VERSION = "47.3.5";
|
|
||||||
|
|
||||||
public VmodExtras() {
|
|
||||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
|
||||||
|
|
||||||
modEventBus.addListener(this::commonSetup);
|
|
||||||
REGISTRY.register(modEventBus);
|
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.COMMON_CONFIG);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void commonSetup(final FMLCommonSetupEvent event) {
|
|
||||||
GameRulesBlat.init();
|
|
||||||
|
|
||||||
String currentVersion = ForgeVersion.getVersion();
|
|
||||||
if (compareVersion(currentVersion, MIN_FORGE_VERSION) < 0) {
|
|
||||||
throw new ModLoadingException(
|
|
||||||
ModLoadingContext.get().getActiveContainer().getModInfo(),
|
|
||||||
ModLoadingStage.ERROR,
|
|
||||||
"VModExras requires Forge " + MIN_FORGE_VERSION + " or higher, but found " + currentVersion,
|
|
||||||
new VerifyException("VModExras requires Forge " + MIN_FORGE_VERSION + " or higher, but found " + currentVersion)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static int compareVersion(String v1, String v2) {
|
|
||||||
if (v1 == null || v2 == null) {
|
|
||||||
throw new IllegalArgumentException("Version strings must not be null");
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] parts1 = v1.split("[.-]");
|
|
||||||
String[] parts2 = v2.split("[.-]");
|
|
||||||
|
|
||||||
int maxLength = Math.max(parts1.length, parts2.length);
|
|
||||||
|
|
||||||
for (int i = 0; i < maxLength; i++) {
|
|
||||||
String s1 = i < parts1.length ? parts1[i] : "0";
|
|
||||||
String s2 = i < parts2.length ? parts2[i] : "0";
|
|
||||||
try {
|
|
||||||
int n1 = Integer.parseInt(s1);
|
|
||||||
int n2 = Integer.parseInt(s2);
|
|
||||||
if (n1 != n2) {
|
|
||||||
return Integer.compare(n1, n2);
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
int cmp = s1.compareTo(s2);
|
|
||||||
if (cmp != 0) {
|
|
||||||
return cmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
|
||||||
public static class ModConfigHandler {
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onConfigReload(ModConfigEvent event) {
|
|
||||||
if (event.getConfig().getSpec() == Config.COMMON_CONFIG) {
|
|
||||||
Config.bake();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.DEDICATED_SERVER)
|
|
||||||
public static class InteractionHandler {
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onRightClickItem(PlayerInteractEvent.RightClickItem event) {
|
|
||||||
if (Config.contains(event.getItemStack())) {
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onRightClickBlock(PlayerInteractEvent.RightClickBlock event) {
|
|
||||||
if (Config.contains(event.getItemStack())) {
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock event) {
|
|
||||||
if (Config.contains(event.getItemStack())) {
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc;
|
|
||||||
|
|
||||||
import io.p2vman.vmodextras.cc.block.BlockNetworkModem;
|
|
||||||
import io.p2vman.vmodextras.cc.block.WireNetworkHubBlock;
|
|
||||||
import io.p2vman.vmodextras.cc.block.entity.NetworkModemEntity;
|
|
||||||
import net.minecraft.world.item.BlockItem;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.Rarity;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
||||||
import net.minecraft.world.level.material.MapColor;
|
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
|
||||||
import io.p2vman.vmodextras.cc.block.TrackWorkController;
|
|
||||||
import io.p2vman.vmodextras.cc.block.entity.TrackWorkControllerEntity;
|
|
||||||
import io.p2vman.vmodextras.util.ModRegistry;
|
|
||||||
import io.p2vman.vmodextras.util.Utils;
|
|
||||||
|
|
||||||
public class ComputerCraftCompact {
|
|
||||||
public static ModRegistry.RegistryContainer NETWORK_MODEM = ModRegistry.RegistryContainer.create("network_modem");
|
|
||||||
public static RegistryObject<BlockEntityType<TrackWorkControllerEntity>> TRACK_WORK_CONTROLLER_BLOCK_ENTITY;
|
|
||||||
|
|
||||||
public static RegistryObject<Block> TRACK_WORK_CONTROLLER_BLOCK;
|
|
||||||
public static RegistryObject<Item> TRACK_WORK_CONTROLLER_ITEM;
|
|
||||||
|
|
||||||
public static RegistryObject<Block> WIRE_NETWORK_HUB_BLOCK;
|
|
||||||
public static RegistryObject<Item> WIRE_NETWORK_HUB_ITEM;
|
|
||||||
|
|
||||||
public static void init(ModRegistry REGISTRY, ModRegistry.TabBuilder builder) {
|
|
||||||
|
|
||||||
NETWORK_MODEM.block(() -> new BlockNetworkModem(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
|
||||||
NETWORK_MODEM.entity(() -> BlockEntityType.Builder.of(NetworkModemEntity::new, NETWORK_MODEM.getBlock().get()).build(null));
|
|
||||||
NETWORK_MODEM.item(() -> new BlockItem(NETWORK_MODEM.getBlock().get(), new Item.Properties().rarity(Rarity.EPIC)));
|
|
||||||
|
|
||||||
Utils.executeIsModEnable("trackwork", () -> {
|
|
||||||
TRACK_WORK_CONTROLLER_BLOCK = REGISTRY.BLOCKS.register("track_work_controller", () -> new TrackWorkController(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
|
||||||
|
|
||||||
TRACK_WORK_CONTROLLER_BLOCK_ENTITY = REGISTRY.BLOCK_ENTITIES.register("track_work_controller", () -> BlockEntityType.Builder.of(TrackWorkControllerEntity::new, TRACK_WORK_CONTROLLER_BLOCK.get()).build(null));
|
|
||||||
});
|
|
||||||
|
|
||||||
//Utils.executeIsModEnable("drivebywire", () -> {
|
|
||||||
// WIRE_NETWORK_HUB_BLOCK = REGISTRY.BLOCKS.register("wire_network_hub", () -> new WireNetworkHubBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
|
||||||
//});
|
|
||||||
|
|
||||||
NETWORK_MODEM.register(REGISTRY);
|
|
||||||
NETWORK_MODEM.register(builder);
|
|
||||||
|
|
||||||
builder.push((registry) -> {
|
|
||||||
Utils.executeIsModEnable("trackwork", () -> {
|
|
||||||
TRACK_WORK_CONTROLLER_ITEM = registry.register("track_work_controller", () -> new BlockItem(TRACK_WORK_CONTROLLER_BLOCK.get(), new Item.Properties().rarity(Rarity.EPIC)));
|
|
||||||
});
|
|
||||||
|
|
||||||
//Utils.executeIsModEnable("drivebywire", () -> {
|
|
||||||
// WIRE_NETWORK_HUB_ITEM = registry.register("wire_network_hub", () -> new BlockItem(WIRE_NETWORK_HUB_BLOCK.get(), new Item.Properties().rarity(Rarity.EPIC)));
|
|
||||||
//});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,127 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.block;
|
|
||||||
|
|
||||||
import dan200.computercraft.shared.peripheral.modem.ModemShapes;
|
|
||||||
import dan200.computercraft.shared.util.WaterloggableHelpers;
|
|
||||||
import io.p2vman.vmodextras.cc.ComputerCraftCompact;
|
|
||||||
import io.p2vman.vmodextras.cc.block.entity.NetworkModemEntity;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.util.RandomSource;
|
|
||||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
|
||||||
import net.minecraft.world.level.BlockGetter;
|
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
|
||||||
import net.minecraft.world.level.LevelReader;
|
|
||||||
import net.minecraft.world.level.block.*;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.level.block.state.StateDefinition;
|
|
||||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
|
||||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
|
||||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
|
||||||
import net.minecraft.world.level.material.FluidState;
|
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import static dan200.computercraft.shared.util.WaterloggableHelpers.WATERLOGGED;
|
|
||||||
import static dan200.computercraft.shared.util.WaterloggableHelpers.getFluidStateForPlacement;
|
|
||||||
|
|
||||||
public class BlockNetworkModem extends DirectionalBlock implements SimpleWaterloggedBlock, EntityBlock
|
|
||||||
{
|
|
||||||
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
|
||||||
public static final BooleanProperty ON = BooleanProperty.create( "on" );
|
|
||||||
|
|
||||||
public BlockNetworkModem(Properties settings)
|
|
||||||
{
|
|
||||||
super(settings);
|
|
||||||
registerDefaultState( getStateDefinition().any()
|
|
||||||
.setValue( FACING, Direction.NORTH )
|
|
||||||
.setValue( ON, false )
|
|
||||||
.setValue( WATERLOGGED, false ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void createBlockStateDefinition( StateDefinition.Builder<Block, BlockState> builder )
|
|
||||||
{
|
|
||||||
builder.add( FACING, ON, WATERLOGGED );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public VoxelShape getShape(BlockState blockState, @Nonnull BlockGetter blockView, @Nonnull BlockPos blockPos, @Nonnull CollisionContext context )
|
|
||||||
{
|
|
||||||
return ModemShapes.getBounds( blockState.getValue( FACING ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public FluidState getFluidState(@Nonnull BlockState state )
|
|
||||||
{
|
|
||||||
return WaterloggableHelpers.getFluidState( state );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public BlockState updateShape(@Nonnull BlockState state, @Nonnull Direction side, @Nonnull BlockState otherState, @Nonnull LevelAccessor world, @Nonnull BlockPos pos, @Nonnull BlockPos otherPos )
|
|
||||||
{
|
|
||||||
WaterloggableHelpers.updateShape( state, world, pos );
|
|
||||||
return side == state.getValue( FACING ) && !state.canSurvive( world, pos )
|
|
||||||
? state.getFluidState().createLegacyBlock()
|
|
||||||
: state;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public boolean canSurvive(BlockState state, @Nonnull LevelReader world, BlockPos pos )
|
|
||||||
{
|
|
||||||
Direction facing = state.getValue( FACING );
|
|
||||||
return canSupportCenter( world, pos.relative( facing ), facing.getOpposite() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public BlockState getStateForPlacement( BlockPlaceContext placement )
|
|
||||||
{
|
|
||||||
return defaultBlockState()
|
|
||||||
.setValue( FACING, placement.getClickedFace().getOpposite() )
|
|
||||||
.setValue( WATERLOGGED, getFluidStateForPlacement( placement ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public BlockState mirror( BlockState state, Mirror mirrorIn )
|
|
||||||
{
|
|
||||||
return state.rotate( mirrorIn.getRotation( state.getValue( FACING ) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public BlockState rotate( BlockState state, Rotation rot )
|
|
||||||
{
|
|
||||||
return state.setValue( FACING, rot.rotate( state.getValue( FACING ) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@org.jetbrains.annotations.Nullable
|
|
||||||
@Override
|
|
||||||
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
|
|
||||||
return ComputerCraftCompact.NETWORK_MODEM.getEntity().get().create(blockPos, blockState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource rand) {
|
|
||||||
BlockEntity te = level.getBlockEntity(pos);
|
|
||||||
if (te instanceof NetworkModemEntity modem) {
|
|
||||||
modem.blockTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.block;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import io.p2vman.vmodextras.cc.ComputerCraftCompact;
|
|
||||||
import io.p2vman.vmodextras.cc.block.entity.TrackWorkControllerEntity;
|
|
||||||
import io.p2vman.vmodextras.util.IBlockEntity;
|
|
||||||
|
|
||||||
public class TrackWorkController extends Block implements IBlockEntity<TrackWorkControllerEntity> {
|
|
||||||
public TrackWorkController(Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockEntityType<? extends TrackWorkControllerEntity> getBlockEntityType() {
|
|
||||||
return ComputerCraftCompact.TRACK_WORK_CONTROLLER_BLOCK_ENTITY.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level p_153212_, BlockState p_153213_, BlockEntityType<T> p_153214_) {
|
|
||||||
return IBlockEntity.super.getTicker(p_153212_, p_153213_, p_153214_);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.block;
|
|
||||||
|
|
||||||
import edn.stratodonut.drivebywire.wire.MultiChannelWireSource;
|
|
||||||
|
|
||||||
import io.p2vman.vmodextras.util.CollectorFactory;
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.stream.IntStream;
|
|
||||||
|
|
||||||
public class WireNetworkHubBlock extends Block implements MultiChannelWireSource {
|
|
||||||
private static final List<String> channels;
|
|
||||||
public WireNetworkHubBlock(BlockBehaviour.Properties p_49795_) {
|
|
||||||
super(p_49795_);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> wire$getChannels() {
|
|
||||||
return channels;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public String wire$nextChannel(String current, boolean forward) {
|
|
||||||
int curIndex = channels.indexOf(current);
|
|
||||||
return curIndex == -1 ? channels.get(0) : channels.get(Math.floorMod(curIndex + (forward ? 1 : -1), channels.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
||||||
|
|
||||||
static {
|
|
||||||
long seed = 123456789L;
|
|
||||||
int prefixCount = 4;
|
|
||||||
int perPrefix = 5;
|
|
||||||
|
|
||||||
channels = new Random(seed)
|
|
||||||
.ints(prefixCount, 0, CHARACTERS.length() * CHARACTERS.length())
|
|
||||||
.mapToObj(i -> "" + CHARACTERS.charAt(i / CHARACTERS.length()) + CHARACTERS.charAt(i % CHARACTERS.length()))
|
|
||||||
.flatMap(prefix -> IntStream.range(0, perPrefix).mapToObj(i -> prefix + i))
|
|
||||||
.collect(CollectorFactory.toList(ObjectArrayList::new));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,140 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.block.entity;
|
|
||||||
|
|
||||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
|
||||||
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessModemBlock;
|
|
||||||
import dan200.computercraft.shared.util.CapabilityUtil;
|
|
||||||
import dan200.computercraft.shared.util.TickScheduler;
|
|
||||||
import io.p2vman.vmodextras.cc.ComputerCraftCompact;
|
|
||||||
import io.p2vman.vmodextras.cc.net.INetwork;
|
|
||||||
import io.p2vman.vmodextras.cc.net.ModemState;
|
|
||||||
import io.p2vman.vmodextras.cc.net.Network;
|
|
||||||
import io.p2vman.vmodextras.cc.peripheral.net.NetworkModemPeripheral;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import static dan200.computercraft.shared.Capabilities.CAPABILITY_PERIPHERAL;
|
|
||||||
|
|
||||||
public class NetworkModemEntity extends BlockEntity {
|
|
||||||
|
|
||||||
private static class Peripheral extends NetworkModemPeripheral
|
|
||||||
{
|
|
||||||
private final NetworkModemEntity entity;
|
|
||||||
|
|
||||||
Peripheral( NetworkModemEntity entity )
|
|
||||||
{
|
|
||||||
super(new ModemState(() -> TickScheduler.schedule(entity.tickToken )));
|
|
||||||
this.entity = entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public Level getLevel()
|
|
||||||
{
|
|
||||||
return entity.getLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public Vec3 getPosition()
|
|
||||||
{
|
|
||||||
return Vec3.atLowerCornerOf( entity.getBlockPos().relative( entity.getDirection() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals( IPeripheral other )
|
|
||||||
{
|
|
||||||
return this == other || (other instanceof NetworkModemEntity.Peripheral && entity == ((NetworkModemEntity.Peripheral) other).entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public Object getTarget()
|
|
||||||
{
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected INetwork getNetwork() {
|
|
||||||
return Network.getUniversal();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final NetworkModemPeripheral modem;
|
|
||||||
private LazyOptional<IPeripheral> modemCap;
|
|
||||||
@Nullable
|
|
||||||
private Runnable modemChanged;
|
|
||||||
private final TickScheduler.Token tickToken = new TickScheduler.Token( this );
|
|
||||||
|
|
||||||
public NetworkModemEntity(BlockPos pos, BlockState state)
|
|
||||||
{
|
|
||||||
super(ComputerCraftCompact.NETWORK_MODEM.getEntity().get(), pos, state );
|
|
||||||
this.modem = new Peripheral(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void setBlockState(BlockState state) {
|
|
||||||
Direction direction = this.getDirection();
|
|
||||||
super.setBlockState(state);
|
|
||||||
if (this.getDirection() != direction && this.modemChanged != null) {
|
|
||||||
this.modemChanged.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onModemChanged(Runnable callback) {
|
|
||||||
this.modemChanged = callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRemoved() {
|
|
||||||
super.setRemoved();
|
|
||||||
this.modem.removed();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearRemoved() {
|
|
||||||
super.clearRemoved();
|
|
||||||
TickScheduler.schedule(this.tickToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void blockTick()
|
|
||||||
{
|
|
||||||
if( modem.getModemState().pollChanged() ) updateBlockState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private Direction getDirection()
|
|
||||||
{
|
|
||||||
return getBlockState().getValue(WirelessModemBlock.FACING );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateBlockState()
|
|
||||||
{
|
|
||||||
boolean on = modem.getModemState().isOpen();
|
|
||||||
BlockState state = getBlockState();
|
|
||||||
if( state.getValue(WirelessModemBlock.ON ) != on )
|
|
||||||
{
|
|
||||||
getLevel().setBlockAndUpdate( getBlockPos(), state.setValue(WirelessModemBlock.ON, on ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side )
|
|
||||||
{
|
|
||||||
if( cap == CAPABILITY_PERIPHERAL )
|
|
||||||
{
|
|
||||||
if( side != null && getDirection() != side ) return LazyOptional.empty();
|
|
||||||
if( modemCap == null ) modemCap = LazyOptional.of( () -> modem );
|
|
||||||
return modemCap.cast();
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getCapability( cap, side );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.block.entity;
|
|
||||||
|
|
||||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import io.p2vman.vmodextras.cc.ComputerCraftCompact;
|
|
||||||
import io.p2vman.vmodextras.cc.peripheral.TrackWorkControllerPeripheral;
|
|
||||||
|
|
||||||
import static dan200.computercraft.shared.Capabilities.CAPABILITY_PERIPHERAL;
|
|
||||||
|
|
||||||
public class TrackWorkControllerEntity extends BlockEntity {
|
|
||||||
public TrackWorkControllerEntity(BlockPos p_155229_, BlockState p_155230_) {
|
|
||||||
super(ComputerCraftCompact.TRACK_WORK_CONTROLLER_BLOCK_ENTITY.get(), p_155229_, p_155230_);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TrackWorkControllerPeripheral peripheral = new TrackWorkControllerPeripheral(this);
|
|
||||||
private LazyOptional<IPeripheral> peripheralCap;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@NotNull
|
|
||||||
public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, Direction direction) {
|
|
||||||
if (cap == CAPABILITY_PERIPHERAL) {
|
|
||||||
if (peripheralCap == null) {
|
|
||||||
peripheralCap = LazyOptional.of(() -> peripheral);
|
|
||||||
}
|
|
||||||
return peripheralCap.cast();
|
|
||||||
}
|
|
||||||
return super.getCapability(cap, direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void invalidateCaps() {
|
|
||||||
super.invalidateCaps();
|
|
||||||
if (peripheralCap != null) {
|
|
||||||
peripheralCap.invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.net;
|
|
||||||
|
|
||||||
public interface IDomainNameHandler {
|
|
||||||
int find(String domain);
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.net;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public interface INetwork {
|
|
||||||
void addReceiver(@Nonnull IPacketReceiver receiver);
|
|
||||||
void removeReceiver(@Nonnull IPacketReceiver receiver);
|
|
||||||
void transmit(@Nonnull NetworkPacket packet);
|
|
||||||
@Nonnull Set<IDomainNameHandler> getDomainHandlers();
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.net;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public interface IPacketReceiver {
|
|
||||||
@Nonnull
|
|
||||||
Level getLevel();
|
|
||||||
void receive(@Nonnull NetworkPacket packet );
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.net;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public interface IPacketSender {
|
|
||||||
@Nonnull
|
|
||||||
Level getLevel();
|
|
||||||
@Nonnull
|
|
||||||
Vec3 getPosition();
|
|
||||||
@Nonnull
|
|
||||||
String getSenderID();
|
|
||||||
}
|
|
|
@ -1,80 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.net;
|
|
||||||
|
|
||||||
import dan200.computercraft.api.lua.LuaException;
|
|
||||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
|
||||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
|
||||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
|
||||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
public class ModemState {
|
|
||||||
private final Runnable onChanged;
|
|
||||||
private final AtomicBoolean changed = new AtomicBoolean( true );
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private boolean open = false;
|
|
||||||
private final IntSet channels = new IntOpenHashSet();
|
|
||||||
|
|
||||||
public ModemState()
|
|
||||||
{
|
|
||||||
onChanged = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModemState(Runnable onChanged)
|
|
||||||
{
|
|
||||||
this.onChanged = onChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setOpen(boolean open)
|
|
||||||
{
|
|
||||||
if(this.open == open) return;
|
|
||||||
this.open = open;
|
|
||||||
if(!changed.getAndSet( true) && onChanged != null) onChanged.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean pollChanged()
|
|
||||||
{
|
|
||||||
return changed.getAndSet( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOpen(int channel)
|
|
||||||
{
|
|
||||||
synchronized(channels)
|
|
||||||
{
|
|
||||||
return channels.contains(channel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void open(int channel) throws LuaException
|
|
||||||
{
|
|
||||||
synchronized(channels)
|
|
||||||
{
|
|
||||||
if(!channels.contains(channel))
|
|
||||||
{
|
|
||||||
if(channels.size() >= 128) throw new LuaException("Too many open channels");
|
|
||||||
channels.add(channel);
|
|
||||||
setOpen(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close(int channel)
|
|
||||||
{
|
|
||||||
synchronized(channels)
|
|
||||||
{
|
|
||||||
channels.remove(channel);
|
|
||||||
if(channels.isEmpty()) setOpen(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void closeAll()
|
|
||||||
{
|
|
||||||
synchronized(channels)
|
|
||||||
{
|
|
||||||
channels.clear();
|
|
||||||
setOpen(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.net;
|
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntArrayMap;
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
public class Network implements INetwork {
|
|
||||||
private static Network universalNetwork = null;
|
|
||||||
|
|
||||||
public static Network getUniversal()
|
|
||||||
{
|
|
||||||
if( universalNetwork == null ) universalNetwork = new Network();
|
|
||||||
return universalNetwork;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void resetNetworks()
|
|
||||||
{
|
|
||||||
universalNetwork = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Set<IPacketReceiver> receivers = ConcurrentHashMap.newKeySet();
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final Set<IDomainNameHandler> domainHandlers = new ObjectOpenHashSet<>();
|
|
||||||
|
|
||||||
public Network() {
|
|
||||||
domainHandlers.add(new IDomainNameHandler() {
|
|
||||||
private final Map<String, Integer> map = new Object2IntArrayMap<>();
|
|
||||||
private int nextId = 1024;
|
|
||||||
@Override
|
|
||||||
public int find(String domain) {
|
|
||||||
if (nextId > Integer.MAX_VALUE - 1024 - Byte.MAX_VALUE*2 || domain.length()>Byte.MAX_VALUE) return -1;
|
|
||||||
return map.computeIfAbsent(domain, k -> nextId++);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addReceiver(@Nonnull IPacketReceiver receiver)
|
|
||||||
{
|
|
||||||
Objects.requireNonNull( receiver, "device cannot be null" );
|
|
||||||
receivers.add( receiver );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeReceiver(@Nonnull IPacketReceiver receiver)
|
|
||||||
{
|
|
||||||
Objects.requireNonNull( receiver, "device cannot be null" );
|
|
||||||
receivers.remove( receiver );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void transmit(@Nonnull NetworkPacket packet)
|
|
||||||
{
|
|
||||||
Objects.requireNonNull(packet, "packet cannot be null" );
|
|
||||||
for(IPacketReceiver device : receivers )
|
|
||||||
device.receive(packet);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.net;
|
|
||||||
|
|
||||||
|
|
||||||
public record NetworkPacket(int channel,
|
|
||||||
int replyChannel,
|
|
||||||
Object payload,
|
|
||||||
IPacketSender sender) {
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.peripheral;
|
|
||||||
|
|
||||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
|
||||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class PeripheralBase implements IPeripheral {
|
|
||||||
@Getter
|
|
||||||
protected final List<IComputerAccess> connectedComputers = new ObjectArrayList<>();
|
|
||||||
protected final String type;
|
|
||||||
public PeripheralBase(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void detach(@Nullable IComputerAccess computer) {
|
|
||||||
connectedComputers.remove(computer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void attach(@Nonnull IComputerAccess computer) {
|
|
||||||
connectedComputers.add(computer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull String getType() {
|
|
||||||
return this.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(IPeripheral iPeripheral) {
|
|
||||||
return this == iPeripheral;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,122 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.peripheral;
|
|
||||||
|
|
||||||
import dan200.computercraft.api.lua.*;
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2DoubleArrayMap;
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2DoubleMap;
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntArrayMap;
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.joml.Vector3d;
|
|
||||||
import org.joml.Vector3dc;
|
|
||||||
import org.squiddev.cobalt.LuaDouble;
|
|
||||||
import org.valkyrienskies.core.api.ships.ServerShip;
|
|
||||||
import org.valkyrienskies.mod.common.VSGameUtilsKt;
|
|
||||||
import io.p2vman.vmodextras.cc.block.entity.TrackWorkControllerEntity;
|
|
||||||
import io.p2vman.vmodextras.trackwork.IController;
|
|
||||||
|
|
||||||
public class TrackWorkControllerPeripheral extends PeripheralBase {
|
|
||||||
private final TrackWorkControllerEntity entity;
|
|
||||||
|
|
||||||
public TrackWorkControllerPeripheral(TrackWorkControllerEntity entity) {
|
|
||||||
super("track_work_controller");
|
|
||||||
this.entity = entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ServerShip cachedShip = null;
|
|
||||||
private Level cachedLevel = null;
|
|
||||||
private BlockPos cachedPos = null;
|
|
||||||
|
|
||||||
private ServerShip getCachedShip() {
|
|
||||||
Level currentLevel = entity.getLevel();
|
|
||||||
BlockPos currentPos = entity.getBlockPos();
|
|
||||||
|
|
||||||
if (cachedShip == null || cachedLevel != currentLevel || !cachedPos.equals(currentPos)) {
|
|
||||||
cachedLevel = currentLevel;
|
|
||||||
cachedPos = currentPos;
|
|
||||||
cachedShip = (ServerShip) VSGameUtilsKt.getShipObjectManagingPos(currentLevel, currentPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
return cachedShip;
|
|
||||||
}
|
|
||||||
|
|
||||||
@LuaFunction(value = {"SetSuspensionAdjust", "setSuspensionAdjust"}, mainThread = true)
|
|
||||||
public final void SetSuspensionAdjust(IArguments arguments) throws LuaException {
|
|
||||||
ServerShip ship = getCachedShip();
|
|
||||||
if (ship != null) {
|
|
||||||
IController controller = IController.getInstance(ship, arguments.getInt(0));
|
|
||||||
|
|
||||||
if (controller != null) {
|
|
||||||
controller.setSuspensionAdjust(new Vector3d(
|
|
||||||
Math.max(Math.min(arguments.getDouble(1), 1d), 0d),
|
|
||||||
Math.max(Math.min(arguments.getDouble(2), 1.3d), 0.5d),
|
|
||||||
Math.max(Math.min(arguments.getDouble(3), 1d), 0d)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@LuaFunction(value = {"SetSuspensionStiffness", "setSuspensionStiffness"}, mainThread = true)
|
|
||||||
public final void SetSuspensionStiffness(IArguments arguments) throws LuaException {
|
|
||||||
ServerShip ship = getCachedShip();
|
|
||||||
if (ship != null) {
|
|
||||||
IController controller = IController.getInstance(ship, arguments.getInt(0));
|
|
||||||
|
|
||||||
if (controller != null) {
|
|
||||||
controller.setSuspensionStiffness((float) Math.min(Math.max(arguments.getDouble(1), 0.6d), 1.5d));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@LuaFunction(value = {"GetSuspensionStiffness", "getSuspensionStiffness"}, mainThread = true)
|
|
||||||
public final MethodResult GetSuspensionStiffness(IArguments arguments) throws LuaException {
|
|
||||||
ServerShip ship = getCachedShip();;
|
|
||||||
if (ship != null) {
|
|
||||||
IController controller = IController.getInstance(ship, arguments.getInt(0));
|
|
||||||
|
|
||||||
if (controller != null) {
|
|
||||||
return MethodResult.of(LuaDouble.valueOf(controller.getSuspensionStiffness()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return MethodResult.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
@LuaFunction(value = {"GetSuspensionAdjust", "getSuspensionAdjust"}, mainThread = true)
|
|
||||||
public final MethodResult GetSuspensionAdjust(IArguments arguments) throws LuaException {
|
|
||||||
ServerShip ship = getCachedShip();
|
|
||||||
if (ship != null) {
|
|
||||||
IController controller = IController.getInstance(ship, arguments.getInt(0));
|
|
||||||
|
|
||||||
if (controller != null) {
|
|
||||||
Int2DoubleMap map = new Int2DoubleArrayMap();
|
|
||||||
Vector3dc vec = controller.getSuspensionAdjust();
|
|
||||||
|
|
||||||
map.put(1, vec.x());
|
|
||||||
map.put(2, vec.y());
|
|
||||||
map.put(3, vec.z());
|
|
||||||
|
|
||||||
return MethodResult.of(new ObjectLuaTable(map));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return MethodResult.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
@LuaFunction(value = {"HasControllers", "hasControllers"}, mainThread = true)
|
|
||||||
public final MethodResult HasControllers() {
|
|
||||||
ServerShip ship = getCachedShip();
|
|
||||||
Object2IntMap<String> map = new Object2IntArrayMap<>();
|
|
||||||
if (ship != null) {
|
|
||||||
if (ship.getAttachment(PhysicsTrackController.class) != null) {
|
|
||||||
map.put("PhysicsTrack", IController.PhysicsTrack);
|
|
||||||
}
|
|
||||||
if (ship.getAttachment(SimpleWheelController.class) != null) {
|
|
||||||
map.put("SimpleWheel", IController.SimpleWheel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return MethodResult.of(new ObjectLuaTable(map));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,174 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.peripheral.net;
|
|
||||||
|
|
||||||
import dan200.computercraft.api.lua.LuaException;
|
|
||||||
import dan200.computercraft.api.lua.LuaFunction;
|
|
||||||
import dan200.computercraft.api.lua.LuaValues;
|
|
||||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
|
||||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
|
||||||
import io.p2vman.vmodextras.cc.net.*;
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public abstract class NetworkModemPeripheral implements IPeripheral, IPacketSender, IPacketReceiver
|
|
||||||
{
|
|
||||||
private INetwork network;
|
|
||||||
private final Set<IComputerAccess> computers = new ObjectOpenHashSet<>(1);
|
|
||||||
private final ModemState state;
|
|
||||||
|
|
||||||
protected NetworkModemPeripheral(ModemState state)
|
|
||||||
{
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModemState getModemState()
|
|
||||||
{
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized void setNetwork( INetwork network )
|
|
||||||
{
|
|
||||||
if( this.network == network ) return;
|
|
||||||
|
|
||||||
// Leave old network
|
|
||||||
if( this.network != null ) this.network.removeReceiver( this );
|
|
||||||
|
|
||||||
// Set new network
|
|
||||||
this.network = network;
|
|
||||||
|
|
||||||
// Join new network
|
|
||||||
if( this.network != null ) this.network.addReceiver( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void destroy()
|
|
||||||
{
|
|
||||||
setNetwork( null );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive(@Nonnull NetworkPacket packet )
|
|
||||||
{
|
|
||||||
if(packet.sender() == this || !state.isOpen(packet.channel())) return;
|
|
||||||
|
|
||||||
synchronized(computers)
|
|
||||||
{
|
|
||||||
for(IComputerAccess computer : computers )
|
|
||||||
{
|
|
||||||
computer.queueEvent( "modem_message",
|
|
||||||
computer.getAttachmentName(), packet.channel(), packet.replyChannel(), packet.payload() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removed() {
|
|
||||||
this.setNetwork(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract INetwork getNetwork();
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public String getType()
|
|
||||||
{
|
|
||||||
return "modem";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int parseChannel(int channel) throws LuaException
|
|
||||||
{
|
|
||||||
if (channel < 0) throw LuaValues.badField("channel", "channel<0", "0");
|
|
||||||
return channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@LuaFunction
|
|
||||||
public final void open(int channel) throws LuaException
|
|
||||||
{
|
|
||||||
state.open(parseChannel(channel));
|
|
||||||
}
|
|
||||||
|
|
||||||
@LuaFunction
|
|
||||||
public final boolean isOpen(int channel) throws LuaException
|
|
||||||
{
|
|
||||||
return state.isOpen(parseChannel(channel));
|
|
||||||
}
|
|
||||||
|
|
||||||
@LuaFunction
|
|
||||||
public final void close(int channel) throws LuaException
|
|
||||||
{
|
|
||||||
state.close(parseChannel(channel));
|
|
||||||
}
|
|
||||||
|
|
||||||
@LuaFunction
|
|
||||||
public final void closeAll()
|
|
||||||
{
|
|
||||||
state.closeAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@LuaFunction
|
|
||||||
public final int findDomain(String domain) {
|
|
||||||
for (IDomainNameHandler handler : this.network.getDomainHandlers()) {
|
|
||||||
int a = handler.find(domain);
|
|
||||||
if (a != -1) return a;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@LuaFunction
|
|
||||||
public final void transmit(int channel, int replyChannel, Object payload ) throws LuaException
|
|
||||||
{
|
|
||||||
parseChannel(channel);
|
|
||||||
parseChannel(replyChannel);
|
|
||||||
|
|
||||||
Level world = getLevel();
|
|
||||||
Vec3 position = getPosition();
|
|
||||||
INetwork network = this.network;
|
|
||||||
|
|
||||||
if( world == null || position == null || network == null ) return;
|
|
||||||
|
|
||||||
network.transmit(new NetworkPacket( channel, replyChannel, payload, this ));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized void attach(@Nonnull IComputerAccess computer)
|
|
||||||
{
|
|
||||||
synchronized( computers )
|
|
||||||
{
|
|
||||||
computers.add( computer );
|
|
||||||
}
|
|
||||||
|
|
||||||
setNetwork( getNetwork() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized void detach(@Nonnull IComputerAccess computer)
|
|
||||||
{
|
|
||||||
boolean empty;
|
|
||||||
synchronized(computers)
|
|
||||||
{
|
|
||||||
computers.remove(computer);
|
|
||||||
empty = computers.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(empty) setNetwork(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public String getSenderID()
|
|
||||||
{
|
|
||||||
synchronized( computers )
|
|
||||||
{
|
|
||||||
if( computers.size() != 1 )
|
|
||||||
{
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IComputerAccess computer = computers.iterator().next();
|
|
||||||
return computer.getID() + "_" + computer.getAttachmentName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package io.p2vman.vmodextras.compact;
|
|
||||||
|
|
||||||
import io.p2vman.vmodextras.cc.ComputerCraftCompact;
|
|
||||||
import io.p2vman.vmodextras.trackwork.TrackWorkCompact;
|
|
||||||
import io.p2vman.vmodextras.util.Utils;
|
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
|
||||||
import net.minecraft.world.item.Items;
|
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
|
||||||
import io.p2vman.vmodextras.VmodExtras;
|
|
||||||
import io.p2vman.vmodextras.util.ModRegistry;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
|
|
||||||
public class Compact {
|
|
||||||
public static RegistryObject<CreativeModeTab> COMPACT_TAB;
|
|
||||||
|
|
||||||
public Compact(BiConsumer<ModRegistry, ModRegistry.TabBuilder> consumer) {
|
|
||||||
ModRegistry REGISTRY = VmodExtras.REGISTRY;
|
|
||||||
ModRegistry.TabBuilder builder = REGISTRY.TabBuilder();
|
|
||||||
|
|
||||||
Utils.executeIsModEnable("computercraft", () -> {
|
|
||||||
ComputerCraftCompact.init(REGISTRY, builder);
|
|
||||||
});
|
|
||||||
|
|
||||||
Utils.executeIsModEnable("trackwork", () -> {
|
|
||||||
TrackWorkCompact.init(REGISTRY, builder);
|
|
||||||
});
|
|
||||||
|
|
||||||
consumer.accept(REGISTRY, builder);
|
|
||||||
|
|
||||||
COMPACT_TAB = builder.build("vmodextras", Items.PAPER.getDefaultInstance());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package io.p2vman.vmodextras.main;
|
|
||||||
|
|
||||||
public class Main {
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
Runtime.getRuntime().exec(new String[]{
|
|
||||||
"konsole", "--noclose", "-e", "bash", "-c", "echo Hello from vmodextras; exec bash"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
package io.p2vman.vmodextras.mixin;
|
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
|
||||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
|
||||||
|
|
||||||
import org.objectweb.asm.tree.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class MixinPlugin implements IMixinConfigPlugin {
|
|
||||||
@Override
|
|
||||||
public void onLoad(String mixinPackage) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRefMapperConfig() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getMixins() {
|
|
||||||
return List.of();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postApply(String targetClassName, ClassNode classNode, String mixinClassName, IMixinInfo mixinInfo) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
@ApiStatus.Experimental
|
|
||||||
package io.p2vman.vmodextras.mixin;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
|
|
@ -1,63 +0,0 @@
|
||||||
package io.p2vman.vmodextras.mixins.create;
|
|
||||||
|
|
||||||
import com.simibubi.create.content.redstone.link.controller.LecternControllerBlock;
|
|
||||||
import com.simibubi.create.content.redstone.link.controller.LecternControllerBlockEntity;
|
|
||||||
import com.simibubi.create.content.schematics.requirement.ISpecialBlockItemRequirement;
|
|
||||||
import com.simibubi.create.foundation.block.IBE;
|
|
||||||
import io.p2vman.vmodextras.GameRulesBlat;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
|
||||||
import net.minecraft.world.InteractionResult;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.level.GameType;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.block.LecternBlock;
|
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
|
|
||||||
@Mixin(value = {LecternControllerBlock.class}, priority = 0)
|
|
||||||
public abstract class LecternControllerBlockMixin extends LecternBlock implements IBE<LecternControllerBlockEntity>, ISpecialBlockItemRequirement {
|
|
||||||
@Shadow public abstract void replaceWithLectern(BlockState state, Level world, BlockPos pos);
|
|
||||||
|
|
||||||
public LecternControllerBlockMixin(BlockBehaviour.Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
this.registerDefaultState(this.defaultBlockState().setValue(HAS_BOOK, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author
|
|
||||||
* @reason
|
|
||||||
*/
|
|
||||||
@Overwrite
|
|
||||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
|
||||||
if (!player.isShiftKeyDown() && LecternControllerBlockEntity.playerInRange(player, world, pos)) {
|
|
||||||
if (!world.isClientSide) {
|
|
||||||
this.withBlockEntityDo(world, pos, (be) -> {
|
|
||||||
be.tryStartUsing(player);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return InteractionResult.SUCCESS;
|
|
||||||
} else if (player.isShiftKeyDown()) {
|
|
||||||
if (!world.isClientSide) {
|
|
||||||
if (!world.getGameRules().getBoolean(GameRulesBlat.EX4)) {
|
|
||||||
if (player instanceof ServerPlayer f && f.gameMode.getGameModeForPlayer() != GameType.ADVENTURE) {
|
|
||||||
this.replaceWithLectern(state, world, pos);
|
|
||||||
return InteractionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.replaceWithLectern(state, world, pos);
|
|
||||||
return InteractionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return InteractionResult.PASS;
|
|
||||||
} else {
|
|
||||||
return InteractionResult.PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package io.p2vman.vmodextras.mixins.create;
|
|
||||||
|
|
||||||
import com.llamalad7.mixinextras.sugar.Local;
|
|
||||||
import com.simibubi.create.content.redstone.link.LinkHandler;
|
|
||||||
import io.p2vman.vmodextras.GameRulesBlat;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.level.GameType;
|
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(LinkHandler.class)
|
|
||||||
public class LinkHandlerMixin {
|
|
||||||
@Inject(method = "onBlockActivated", at = @At(value = "INVOKE", target = "Ljava/util/Arrays;asList([Ljava/lang/Object;)Ljava/util/List;"), cancellable = true, remap = false)
|
|
||||||
private static void Abc(PlayerInteractEvent.RightClickBlock event, CallbackInfo ci) {
|
|
||||||
if (event.getEntity() instanceof ServerPlayer p && p.gameMode.getGameModeForPlayer() == GameType.ADVENTURE && !event.getLevel().getGameRules().getBoolean(GameRulesBlat.EX4)) {
|
|
||||||
event.setCanceled(true);
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package io.p2vman.vmodextras.mixins.create;
|
|
||||||
|
|
||||||
import com.simibubi.create.content.redstone.link.RedstoneLinkBlock;
|
|
||||||
import io.p2vman.vmodextras.GameRulesBlat;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
|
||||||
import net.minecraft.world.InteractionResult;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.level.GameType;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
|
|
||||||
@Mixin(RedstoneLinkBlock.class)
|
|
||||||
public class RedstoneLinkBlockMixin {
|
|
||||||
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
|
|
||||||
private void B(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit, CallbackInfoReturnable<InteractionResult> cir) {
|
|
||||||
if (!worldIn.isClientSide && (player instanceof ServerPlayer f && f.gameMode.getGameModeForPlayer() == GameType.ADVENTURE && !worldIn.getGameRules().getBoolean(GameRulesBlat.EX4))) {
|
|
||||||
cir.setReturnValue(InteractionResult.PASS);
|
|
||||||
cir.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
package io.p2vman.vmodextras.mixins.create_tweaked_controllers;
|
|
||||||
|
|
||||||
import com.getitemfromblock.create_tweaked_controllers.block.TweakedLecternControllerBlockEntity;
|
|
||||||
import com.simibubi.create.content.redstone.link.controller.LecternControllerBlockEntity;
|
|
||||||
import com.simibubi.create.content.schematics.requirement.ISpecialBlockItemRequirement;
|
|
||||||
import com.simibubi.create.foundation.block.IBE;
|
|
||||||
import io.p2vman.vmodextras.GameRulesBlat;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.player.AbstractClientPlayer;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
|
||||||
import net.minecraft.world.InteractionResult;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.level.GameType;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.block.LecternBlock;
|
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import com.getitemfromblock.create_tweaked_controllers.block.TweakedLecternControllerBlock;
|
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
|
|
||||||
@Mixin(value = TweakedLecternControllerBlock.class, priority = 0)
|
|
||||||
public abstract class TweakedLecternControllerBlockMixin extends LecternBlock implements IBE<TweakedLecternControllerBlockEntity>, ISpecialBlockItemRequirement {
|
|
||||||
@Shadow
|
|
||||||
public abstract void replaceWithLectern(BlockState state, Level world, BlockPos pos);
|
|
||||||
|
|
||||||
public TweakedLecternControllerBlockMixin(BlockBehaviour.Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
this.registerDefaultState(this.defaultBlockState().setValue(HAS_BOOK, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author
|
|
||||||
* @reason
|
|
||||||
*/
|
|
||||||
@Overwrite
|
|
||||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
|
||||||
if (!player.isShiftKeyDown() && TweakedLecternControllerBlockEntity.playerInRange(player, world, pos)) {
|
|
||||||
if (!world.isClientSide) {
|
|
||||||
this.withBlockEntityDo(world, pos, (be) -> {
|
|
||||||
be.tryStartUsing(player);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return InteractionResult.SUCCESS;
|
|
||||||
} else if (player.isShiftKeyDown()) {
|
|
||||||
if (!world.isClientSide) {
|
|
||||||
if (!world.getGameRules().getBoolean(GameRulesBlat.EX4)) {
|
|
||||||
if (player instanceof ServerPlayer f && f.gameMode.getGameModeForPlayer() != GameType.ADVENTURE) {
|
|
||||||
this.replaceWithLectern(state, world, pos);
|
|
||||||
return InteractionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.replaceWithLectern(state, world, pos);
|
|
||||||
return InteractionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return InteractionResult.PASS;
|
|
||||||
} else {
|
|
||||||
return InteractionResult.PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package io.p2vman.vmodextras.mixins.trackwork;
|
|
||||||
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
|
||||||
import org.joml.Vector3dc;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
|
||||||
|
|
||||||
@Mixin(PhysicsTrackController.class)
|
|
||||||
public interface PhysicsTrackControllerAccessor {
|
|
||||||
@Accessor(value = "suspensionStiffness", remap = false)
|
|
||||||
float getSuspensionStiffness();
|
|
||||||
|
|
||||||
@Accessor(value = "suspensionStiffness", remap = false)
|
|
||||||
void setSuspensionStiffness(float val);
|
|
||||||
|
|
||||||
@Accessor(value = "suspensionAdjust", remap = false)
|
|
||||||
Vector3dc getSuspensionAdjust();
|
|
||||||
|
|
||||||
@Accessor(value = "suspensionAdjust", remap = false)
|
|
||||||
void setSuspensionAdjust(Vector3dc vector3d);
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package io.p2vman.vmodextras.mixins.trackwork;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
|
||||||
import org.joml.Math;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import io.p2vman.vmodextras.Config;
|
|
||||||
import io.p2vman.vmodextras.trackwork.IPhysicsTrackController;
|
|
||||||
|
|
||||||
@Mixin(PhysicsTrackController.class)
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public abstract class PhysicsTrackControllerMixin implements IPhysicsTrackController {
|
|
||||||
@Shadow(remap = false) private volatile float suspensionStiffness;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author
|
|
||||||
* @reason
|
|
||||||
*/
|
|
||||||
@Overwrite(remap = false)
|
|
||||||
public final float setDamperCoefficient(float delta) {
|
|
||||||
this.suspensionStiffness = Math.clamp(1, Config.Suspension_Stiffness_LIMIT.get(), this.suspensionStiffness + delta);
|
|
||||||
return this.suspensionStiffness;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package io.p2vman.vmodextras.mixins.trackwork;
|
|
||||||
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
|
||||||
import org.joml.Vector3dc;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
|
||||||
|
|
||||||
@Mixin(SimpleWheelController.class)
|
|
||||||
public interface SimpleWheelControllerAccessor {
|
|
||||||
@Accessor(value = "suspensionStiffness", remap = false)
|
|
||||||
float getSuspensionStiffness();
|
|
||||||
|
|
||||||
@Accessor(value = "suspensionStiffness", remap = false)
|
|
||||||
void setSuspensionStiffness(float val);
|
|
||||||
|
|
||||||
@Accessor(value = "suspensionAdjust", remap = false)
|
|
||||||
Vector3dc getSuspensionAdjust();
|
|
||||||
|
|
||||||
@Accessor(value = "suspensionAdjust", remap = false)
|
|
||||||
void setSuspensionAdjust(Vector3dc vector3d);
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package io.p2vman.vmodextras.mixins.trackwork;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
|
||||||
import org.joml.Math;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import io.p2vman.vmodextras.Config;
|
|
||||||
import io.p2vman.vmodextras.trackwork.ISimpleWheelController;
|
|
||||||
|
|
||||||
@Mixin(SimpleWheelController.class)
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public abstract class SimpleWheelControllerMixin implements ISimpleWheelController {
|
|
||||||
@Shadow(remap = false) private volatile float suspensionStiffness;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author
|
|
||||||
* @reason
|
|
||||||
*/
|
|
||||||
@Overwrite(remap = false)
|
|
||||||
public final float setDamperCoefficient(float delta) {
|
|
||||||
this.suspensionStiffness = Math.clamp(1, Config.Suspension_Stiffness_LIMIT.get(), this.suspensionStiffness + delta);
|
|
||||||
return this.suspensionStiffness;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package io.p2vman.vmodextras.mixins.trackwork;
|
|
||||||
|
|
||||||
import edn.stratodonut.trackwork.items.TrackToolkit;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
|
|
||||||
@Mixin(TrackToolkit.class)
|
|
||||||
public class TrackToolkitMixin {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package io.p2vman.vmodextras.mixins.vmod;
|
|
||||||
|
|
||||||
|
|
||||||
import io.p2vman.vmodextras.Config;
|
|
||||||
import kotlin.reflect.KProperty;
|
|
||||||
import net.spaceeye.vmod.reflectable.ReflectableItemDelegate;
|
|
||||||
import net.spaceeye.vmod.toolgun.modes.state.ScaleMode;
|
|
||||||
import org.spongepowered.asm.mixin.Final;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
|
|
||||||
@Mixin(ScaleMode.class)
|
|
||||||
public abstract class ScaleModeMixin {
|
|
||||||
@Shadow private @Final ReflectableItemDelegate scale$delegate;
|
|
||||||
@Shadow @Final private static KProperty<Object>[] $$delegatedProperties;
|
|
||||||
|
|
||||||
@Inject(method = "getScale", at = @At("HEAD"), cancellable = true, remap = false)
|
|
||||||
private void vmodextras$getScale(CallbackInfoReturnable<Double> cir) {
|
|
||||||
cir.setReturnValue(Config.SCALE_CLAMP.clamp(((Number)this.scale$delegate.getValue(this, $$delegatedProperties[0])).doubleValue()));
|
|
||||||
cir.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package io.p2vman.vmodextras.mixins.vmod;
|
|
||||||
|
|
||||||
import net.spaceeye.vmod.utils.vs.TeleportShipWithConnectedKt;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
|
|
||||||
@Mixin(TeleportShipWithConnectedKt.class)
|
|
||||||
public class TeleportShipWithConnectedKtMixin {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
package io.p2vman.vmodextras.serialization;
|
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
|
||||||
import lombok.experimental.Delegate;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class Codec<T> {
|
|
||||||
@Delegate
|
|
||||||
private final Decode<T> decode;
|
|
||||||
@Delegate
|
|
||||||
private final Encode<T> encode;
|
|
||||||
|
|
||||||
public static final Map<Class<?>, Codec<?>> codecs = new Object2ObjectArrayMap<>();
|
|
||||||
|
|
||||||
public Codec(Encode<T> encode, Decode<T> decode) {
|
|
||||||
this.decode = decode;
|
|
||||||
this.encode = encode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final <T extends A, A> Codec<T> register(Class<T> cls, Class<A> cls2, Codec<A> codec) {
|
|
||||||
if (!cls2.isAssignableFrom(cls)) throw new RuntimeException();
|
|
||||||
codecs.put(cls, codec);
|
|
||||||
return (Codec<T>) codec;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final <T> Codec<T> register(Class<T> cls, Codec<T> codec) {
|
|
||||||
codecs.put(cls, codec);
|
|
||||||
return codec;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Optional<Codec<T>> getCodec(Class<T> cls) {
|
|
||||||
if (!codecs.containsKey(cls)) return Optional.empty();
|
|
||||||
try {
|
|
||||||
return Optional.ofNullable((Codec<T>) codecs.get(cls));
|
|
||||||
} catch (Exception e) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package io.p2vman.vmodextras.serialization;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import org.valkyrienskies.core.api.ships.ServerShip;
|
|
||||||
|
|
||||||
public record Context(BlockEntity entity, ServerShip ship) {
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package io.p2vman.vmodextras.serialization;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface Decode<T> {
|
|
||||||
T decode(CompoundTag root, T obj, Context context);
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package io.p2vman.vmodextras.serialization;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface Encode<T> {
|
|
||||||
CompoundTag encode(T input, Context context);
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package io.p2vman.vmodextras.trackwork;
|
|
||||||
|
|
||||||
public interface IBlockEntityClear {
|
|
||||||
boolean clear();
|
|
||||||
default boolean reset() {
|
|
||||||
return clear();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package io.p2vman.vmodextras.trackwork;
|
|
||||||
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.Tag;
|
|
||||||
import org.joml.Vector3d;
|
|
||||||
import org.joml.Vector3dc;
|
|
||||||
import org.valkyrienskies.core.api.ships.ServerShip;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public interface IController {
|
|
||||||
float getSuspensionStiffness();
|
|
||||||
void setSuspensionStiffness(float val);
|
|
||||||
@Nonnull Vector3dc getSuspensionAdjust();
|
|
||||||
void setSuspensionAdjust(@Nonnull Vector3dc vector3d);
|
|
||||||
|
|
||||||
int SimpleWheel = 0;
|
|
||||||
int PhysicsTrack = 1;
|
|
||||||
|
|
||||||
static @Nullable IController getInstance(@Nonnull ServerShip ship, int id) {
|
|
||||||
switch (id) {
|
|
||||||
case IController.SimpleWheel -> {
|
|
||||||
return ((IController) SimpleWheelController.getOrCreate(ship));
|
|
||||||
}
|
|
||||||
case IController.PhysicsTrack -> {
|
|
||||||
return ((IController) PhysicsTrackController.getOrCreate(ship));
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package io.p2vman.vmodextras.trackwork;
|
|
||||||
|
|
||||||
import io.p2vman.vmodextras.mixins.trackwork.PhysicsTrackControllerAccessor;
|
|
||||||
|
|
||||||
public interface IPhysicsTrackController extends PhysicsTrackControllerAccessor, IController {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
package io.p2vman.vmodextras.trackwork;
|
|
||||||
|
|
||||||
import io.p2vman.vmodextras.mixins.trackwork.SimpleWheelControllerAccessor;
|
|
||||||
|
|
||||||
public interface ISimpleWheelController extends SimpleWheelControllerAccessor, IController {
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
package io.p2vman.vmodextras.trackwork;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.BlockItem;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.Rarity;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
||||||
import net.minecraft.world.level.material.MapColor;
|
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
|
||||||
import io.p2vman.vmodextras.trackwork.block.CompactBackupBlock;
|
|
||||||
import io.p2vman.vmodextras.trackwork.block.TrackBackupBlock;
|
|
||||||
import io.p2vman.vmodextras.trackwork.block.entity.CompactBackupBlockEntity;
|
|
||||||
import io.p2vman.vmodextras.trackwork.block.entity.TrackBackupBlockEntity;
|
|
||||||
import io.p2vman.vmodextras.util.ModRegistry;
|
|
||||||
|
|
||||||
public class TrackWorkCompact
|
|
||||||
{
|
|
||||||
public static RegistryObject<Block> SHIP_VOID_BLOCK;
|
|
||||||
public static RegistryObject<Block> TRAK_BUK;
|
|
||||||
public static RegistryObject<Block> COMPACT_BACKUP;
|
|
||||||
|
|
||||||
public static RegistryObject<BlockEntityType<TrackBackupBlockEntity>> MY_BLOCK_ENTITY;
|
|
||||||
public static RegistryObject<BlockEntityType<CompactBackupBlockEntity>> COMPACT_BACKUP_BLOCK_ENTITY;
|
|
||||||
|
|
||||||
public static RegistryObject<Item> MY_BLOCK_ITEM;
|
|
||||||
public static RegistryObject<Item> SHIP_VOID_ITEM;
|
|
||||||
public static RegistryObject<Item> COMPACT_BACKUP_ITEM;
|
|
||||||
|
|
||||||
|
|
||||||
public static void init(ModRegistry REGISTRY, ModRegistry.TabBuilder builder) {
|
|
||||||
TRAK_BUK = REGISTRY.BLOCKS.register("track_backup", () -> new TrackBackupBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
|
||||||
SHIP_VOID_BLOCK = REGISTRY.BLOCKS.register("ship_void", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
|
||||||
COMPACT_BACKUP = REGISTRY.BLOCKS.register("compact_backup", () -> new CompactBackupBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
|
||||||
|
|
||||||
MY_BLOCK_ENTITY = REGISTRY.BLOCK_ENTITIES.register("track_backup", () -> BlockEntityType.Builder.of(TrackBackupBlockEntity::new, TRAK_BUK.get()).build(null));
|
|
||||||
COMPACT_BACKUP_BLOCK_ENTITY = REGISTRY.BLOCK_ENTITIES.register("compact_backup", () -> BlockEntityType.Builder.of(CompactBackupBlockEntity::new, COMPACT_BACKUP.get()).build(null));
|
|
||||||
|
|
||||||
builder.push((registry) -> {
|
|
||||||
MY_BLOCK_ITEM = registry.register("track_backup", () -> new BlockItem(TRAK_BUK.get(), new Item.Properties().rarity(Rarity.EPIC)));
|
|
||||||
SHIP_VOID_ITEM = registry.register("ship_void", () -> new BlockItem(SHIP_VOID_BLOCK.get(), new Item.Properties()));
|
|
||||||
COMPACT_BACKUP_ITEM = registry.register("compact_backup", () -> new BlockItem(COMPACT_BACKUP.get(), new Item.Properties().rarity(Rarity.EPIC)));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package io.p2vman.vmodextras.trackwork.block;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
||||||
import io.p2vman.vmodextras.trackwork.TrackWorkCompact;
|
|
||||||
import io.p2vman.vmodextras.trackwork.block.entity.CompactBackupBlockEntity;
|
|
||||||
import io.p2vman.vmodextras.util.IBlockEntity;
|
|
||||||
|
|
||||||
public class CompactBackupBlock extends Block implements IBlockEntity<CompactBackupBlockEntity> {
|
|
||||||
|
|
||||||
public CompactBackupBlock(Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockEntityType<? extends CompactBackupBlockEntity> getBlockEntityType() {
|
|
||||||
return TrackWorkCompact.COMPACT_BACKUP_BLOCK_ENTITY.get();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package io.p2vman.vmodextras.trackwork.block;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
||||||
import io.p2vman.vmodextras.trackwork.TrackWorkCompact;
|
|
||||||
import io.p2vman.vmodextras.trackwork.block.entity.TrackBackupBlockEntity;
|
|
||||||
import io.p2vman.vmodextras.util.IBlockEntity;
|
|
||||||
|
|
||||||
public class TrackBackupBlock extends Block implements IBlockEntity<TrackBackupBlockEntity> {
|
|
||||||
|
|
||||||
public TrackBackupBlock(Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockEntityType<? extends TrackBackupBlockEntity> getBlockEntityType() {
|
|
||||||
return TrackWorkCompact.MY_BLOCK_ENTITY.get();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,85 +0,0 @@
|
||||||
package io.p2vman.vmodextras.trackwork.block.entity;
|
|
||||||
|
|
||||||
import edn.stratodonut.drivebywire.wire.ShipWireNetworkManager;
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
|
||||||
|
|
||||||
import io.p2vman.vmodextras.serialization.Context;
|
|
||||||
import io.p2vman.vmodextras.util.VsUtils;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.Tag;
|
|
||||||
import net.minecraft.world.level.block.Rotation;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
|
|
||||||
import org.valkyrienskies.core.api.ships.ServerShip;
|
|
||||||
import org.valkyrienskies.core.api.ships.Ship;
|
|
||||||
import org.valkyrienskies.mod.common.VSGameUtilsKt;
|
|
||||||
|
|
||||||
import io.p2vman.vmodextras.trackwork.TrackWorkCompact;
|
|
||||||
|
|
||||||
|
|
||||||
public class CompactBackupBlockEntity extends BlockEntity {
|
|
||||||
public CompactBackupBlockEntity(BlockPos p_155229_, BlockState p_155230_) {
|
|
||||||
super(TrackWorkCompact.COMPACT_BACKUP_BLOCK_ENTITY.get(), p_155229_, p_155230_);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void saveAdditional(CompoundTag tag) {
|
|
||||||
super.saveAdditional(tag);
|
|
||||||
|
|
||||||
if (this.level != null) {
|
|
||||||
Ship raw = VSGameUtilsKt.getShipObjectManagingPos(this.level, getBlockPos());
|
|
||||||
if (raw instanceof ServerShip ship) {
|
|
||||||
Context ctx = new Context(this, ship);
|
|
||||||
PhysicsTrackController physicsTrackController = ship.getAttachment(PhysicsTrackController.class);
|
|
||||||
if (physicsTrackController != null) {
|
|
||||||
tag.put("PhysicsTrackController", TrackBackupBlockEntity.PHYSICS_TRACK_CONTROLLER_CODEC.encode(physicsTrackController, ctx));
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleWheelController simpleWheelController = ship.getAttachment(SimpleWheelController.class);
|
|
||||||
if (simpleWheelController != null) {
|
|
||||||
tag.put("SimpleWheelController", TrackBackupBlockEntity.SIMPLE_WHEEL_CONTROLLER_CODEC.encode(simpleWheelController, ctx));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ship raw2 = VSGameUtilsKt.getShipManagingPos(this.level, this.getBlockPos());
|
|
||||||
if (raw2 instanceof ServerShip ship) {
|
|
||||||
CompoundTag BackupData = new CompoundTag();
|
|
||||||
|
|
||||||
ShipWireNetworkManager.get(ship).ifPresent((m) -> BackupData.merge(m.serialiseToNbt(this.level, this.getBlockPos())));
|
|
||||||
|
|
||||||
tag.put("WireNetwork", BackupData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load(CompoundTag tag) {
|
|
||||||
super.load(tag);
|
|
||||||
|
|
||||||
Ship raw = VSGameUtilsKt.getShipObjectManagingPos(this.level, getBlockPos());
|
|
||||||
if (raw instanceof ServerShip ship) {
|
|
||||||
Context ctx = new Context(this, ship);
|
|
||||||
if (tag.contains("SimpleWheelController", Tag.TAG_COMPOUND)) {
|
|
||||||
VsUtils.getOrCreateAttachment(ship, SimpleWheelController.class).ifPresent((controller) -> {
|
|
||||||
TrackBackupBlockEntity.SIMPLE_WHEEL_CONTROLLER_CODEC.decode(tag.getCompound("SimpleWheelController"), controller, ctx);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tag.contains("PhysicsTrackController", Tag.TAG_COMPOUND)) {
|
|
||||||
VsUtils.getOrCreateAttachment(ship, PhysicsTrackController.class).ifPresent((controller) -> {
|
|
||||||
TrackBackupBlockEntity.PHYSICS_TRACK_CONTROLLER_CODEC.decode(tag.getCompound("PhysicsTrackController"), controller, ctx);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ship ship = VSGameUtilsKt.getShipManagingPos(this.level, getBlockPos());
|
|
||||||
if (ship instanceof ServerShip s) {
|
|
||||||
if (tag.contains("WireNetwork", 10)) {
|
|
||||||
ShipWireNetworkManager.loadIfNotExists(s, level, tag.getCompound("WireNetwork"), this.getBlockPos(), Rotation.NONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,100 +0,0 @@
|
||||||
package io.p2vman.vmodextras.trackwork.block.entity;
|
|
||||||
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
|
||||||
import io.p2vman.vmodextras.serialization.Codec;
|
|
||||||
import io.p2vman.vmodextras.serialization.Context;
|
|
||||||
import io.p2vman.vmodextras.trackwork.IController;
|
|
||||||
import io.p2vman.vmodextras.util.VsUtils;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.Tag;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import org.joml.Vector3d;
|
|
||||||
import org.joml.Vector3dc;
|
|
||||||
import org.valkyrienskies.core.api.ships.ServerShip;
|
|
||||||
import org.valkyrienskies.core.api.ships.Ship;
|
|
||||||
import org.valkyrienskies.mod.common.VSGameUtilsKt;
|
|
||||||
import io.p2vman.vmodextras.trackwork.TrackWorkCompact;
|
|
||||||
|
|
||||||
public class TrackBackupBlockEntity extends BlockEntity {
|
|
||||||
public TrackBackupBlockEntity(BlockPos p_155229_, BlockState p_155230_) {
|
|
||||||
super(TrackWorkCompact.MY_BLOCK_ENTITY.get(), p_155229_, p_155230_);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Codec<IController> CONTROLLER_CODEC = new Codec<>((controller, ctx) -> {
|
|
||||||
|
|
||||||
CompoundTag root = new CompoundTag();
|
|
||||||
|
|
||||||
root.putFloat("SuspensionStiffness", controller.getSuspensionStiffness());
|
|
||||||
{
|
|
||||||
CompoundTag suspensionAdjust = new CompoundTag();
|
|
||||||
|
|
||||||
Vector3dc vec = controller.getSuspensionAdjust();
|
|
||||||
|
|
||||||
suspensionAdjust.putDouble("x", vec.x());
|
|
||||||
suspensionAdjust.putDouble("y", vec.y());
|
|
||||||
suspensionAdjust.putDouble("z", vec.z());
|
|
||||||
|
|
||||||
root.put("suspensionAdjust", suspensionAdjust);
|
|
||||||
}
|
|
||||||
|
|
||||||
return root;
|
|
||||||
}, (root, controller, ctx) -> {
|
|
||||||
|
|
||||||
if (root.contains("SuspensionStiffness", Tag.TAG_FLOAT)) {
|
|
||||||
controller.setSuspensionStiffness(root.getFloat("SuspensionStiffness"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (root.contains("suspensionAdjust", Tag.TAG_COMPOUND)) {
|
|
||||||
CompoundTag sus = root.getCompound("suspensionAdjust");
|
|
||||||
controller.setSuspensionAdjust(new Vector3d(sus.getDouble("x"), sus.getDouble("y"), sus.getDouble("z")));
|
|
||||||
}
|
|
||||||
|
|
||||||
return controller;
|
|
||||||
});
|
|
||||||
|
|
||||||
public static final Codec<PhysicsTrackController> PHYSICS_TRACK_CONTROLLER_CODEC = Codec.register(PhysicsTrackController.class, IController.class, CONTROLLER_CODEC);
|
|
||||||
|
|
||||||
public static final Codec<SimpleWheelController> SIMPLE_WHEEL_CONTROLLER_CODEC = Codec.register(SimpleWheelController.class, IController.class, CONTROLLER_CODEC);
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void saveAdditional(CompoundTag tag) {
|
|
||||||
super.saveAdditional(tag);
|
|
||||||
Ship raw = VSGameUtilsKt.getShipObjectManagingPos(this.level, getBlockPos());
|
|
||||||
if (raw instanceof ServerShip ship) {
|
|
||||||
Context ctx = new Context(this, ship);
|
|
||||||
PhysicsTrackController physicsTrackController = ship.getAttachment(PhysicsTrackController.class);
|
|
||||||
if (physicsTrackController != null) {
|
|
||||||
tag.put("PhysicsTrackController", PHYSICS_TRACK_CONTROLLER_CODEC.encode(physicsTrackController, ctx));
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleWheelController simpleWheelController = ship.getAttachment(SimpleWheelController.class);
|
|
||||||
if (simpleWheelController != null) {
|
|
||||||
tag.put("SimpleWheelController", SIMPLE_WHEEL_CONTROLLER_CODEC.encode(simpleWheelController, ctx));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load(CompoundTag tag) {
|
|
||||||
super.load(tag);
|
|
||||||
Ship raw = VSGameUtilsKt.getShipObjectManagingPos(this.level, getBlockPos());
|
|
||||||
if (raw instanceof ServerShip ship) {
|
|
||||||
Context ctx = new Context(this, ship);
|
|
||||||
if (tag.contains("SimpleWheelController", Tag.TAG_COMPOUND)) {
|
|
||||||
VsUtils.getOrCreateAttachment(ship, SimpleWheelController.class).ifPresent((controller) -> {
|
|
||||||
SIMPLE_WHEEL_CONTROLLER_CODEC.decode(tag.getCompound("SimpleWheelController"), controller, ctx);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tag.contains("PhysicsTrackController", Tag.TAG_COMPOUND)) {
|
|
||||||
VsUtils.getOrCreateAttachment(ship, PhysicsTrackController.class).ifPresent((controller) -> {
|
|
||||||
PHYSICS_TRACK_CONTROLLER_CODEC.decode(tag.getCompound("PhysicsTrackController"), controller, ctx);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
package io.p2vman.vmodextras.util;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
import java.util.function.BinaryOperator;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
|
|
||||||
public class CollectorFactory {
|
|
||||||
public static final Set<Collector.Characteristics> CH_CONCURRENT_ID
|
|
||||||
= Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.CONCURRENT,
|
|
||||||
Collector.Characteristics.UNORDERED,
|
|
||||||
Collector.Characteristics.IDENTITY_FINISH));
|
|
||||||
public static final Set<Collector.Characteristics> CH_CONCURRENT_NOID
|
|
||||||
= Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.CONCURRENT,
|
|
||||||
Collector.Characteristics.UNORDERED));
|
|
||||||
public static final Set<Collector.Characteristics> CH_ID
|
|
||||||
= Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.IDENTITY_FINISH));
|
|
||||||
public static final Set<Collector.Characteristics> CH_UNORDERED_ID
|
|
||||||
= Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.UNORDERED,
|
|
||||||
Collector.Characteristics.IDENTITY_FINISH));
|
|
||||||
public static final Set<Collector.Characteristics> CH_NOID = Collections.emptySet();
|
|
||||||
public static final Set<Collector.Characteristics> CH_UNORDERED_NOID
|
|
||||||
= Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.UNORDERED));
|
|
||||||
|
|
||||||
public static class CollectorImpl<T, A, R> implements Collector<T, A, R> {
|
|
||||||
private final Supplier<A> supplier;
|
|
||||||
private final BiConsumer<A, T> accumulator;
|
|
||||||
private final BinaryOperator<A> combiner;
|
|
||||||
private final Function<A, R> finisher;
|
|
||||||
private final Set<Characteristics> characteristics;
|
|
||||||
|
|
||||||
public CollectorImpl(Supplier<A> supplier,
|
|
||||||
BiConsumer<A, T> accumulator,
|
|
||||||
BinaryOperator<A> combiner,
|
|
||||||
Function<A,R> finisher,
|
|
||||||
Set<Characteristics> characteristics) {
|
|
||||||
this.supplier = supplier;
|
|
||||||
this.accumulator = accumulator;
|
|
||||||
this.combiner = combiner;
|
|
||||||
this.finisher = finisher;
|
|
||||||
this.characteristics = characteristics;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CollectorImpl(Supplier<A> supplier,
|
|
||||||
BiConsumer<A, T> accumulator,
|
|
||||||
BinaryOperator<A> combiner,
|
|
||||||
Set<Characteristics> characteristics) {
|
|
||||||
this(supplier, accumulator, combiner, i -> (R) i, characteristics);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BiConsumer<A, T> accumulator() {
|
|
||||||
return accumulator;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Supplier<A> supplier() {
|
|
||||||
return supplier;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BinaryOperator<A> combiner() {
|
|
||||||
return combiner;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Function<A, R> finisher() {
|
|
||||||
return finisher;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<Characteristics> characteristics() {
|
|
||||||
return characteristics;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T, R extends List<T>> Collector<T, ?, List<T>> toList(Supplier<R> supplier) {
|
|
||||||
return new CollectorImpl<>(supplier, List::add, (left, right) -> { left.addAll(right); return left; }, CH_ID);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package io.p2vman.vmodextras.util;
|
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.world.level.block.EntityBlock;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
|
|
||||||
public interface IBlockEntity<T extends BlockEntity> extends EntityBlock {
|
|
||||||
BlockEntityType<? extends T> getBlockEntityType();
|
|
||||||
|
|
||||||
default BlockEntity newBlockEntity(BlockPos p_153215_, BlockState p_153216_) {
|
|
||||||
return this.getBlockEntityType().create(p_153215_, p_153216_);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,193 +0,0 @@
|
||||||
package io.p2vman.vmodextras.util;
|
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.Pair;
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectObjectImmutablePair;
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.minecraft.core.registries.Registries;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
|
||||||
import net.minecraft.world.item.CreativeModeTabs;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class ModRegistry {
|
|
||||||
@Getter
|
|
||||||
private final String modid;
|
|
||||||
|
|
||||||
public final DeferredRegister<Block> BLOCKS;
|
|
||||||
public final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES;
|
|
||||||
public final Map<RegistryObject<CreativeModeTab>, DeferredRegister<Item>> ITEMS;
|
|
||||||
public final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS;
|
|
||||||
|
|
||||||
public ModRegistry(String modid) {
|
|
||||||
this.modid = modid;
|
|
||||||
this.BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, modid);
|
|
||||||
this.BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, modid);
|
|
||||||
this.ITEMS = new Object2ObjectArrayMap<>();
|
|
||||||
this.CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, modid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TabBuilder TabBuilder() {
|
|
||||||
return new TabBuilder(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void register(IEventBus bus) {
|
|
||||||
this.BLOCKS.register(bus);
|
|
||||||
this.BLOCK_ENTITIES.register(bus);
|
|
||||||
this.CREATIVE_MODE_TABS.register(bus);
|
|
||||||
for (DeferredRegister<Item> registry : ITEMS.values()) {
|
|
||||||
registry.register(bus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static class TabBuilder {
|
|
||||||
private final ModRegistry registry;
|
|
||||||
public final DeferredRegister<Item> ITEMS;
|
|
||||||
|
|
||||||
public TabBuilder(ModRegistry registry) {
|
|
||||||
this.registry = registry;
|
|
||||||
this.ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, registry.modid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TabBuilder push(Consumer<DeferredRegister<Item>> registry) {
|
|
||||||
registry.accept(ITEMS);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RegistryObject<CreativeModeTab> build(String name, ItemStack icon) {
|
|
||||||
RegistryObject<CreativeModeTab> tab = this.registry.CREATIVE_MODE_TABS.register(name, () -> CreativeModeTab.builder().withTabsBefore(CreativeModeTabs.COMBAT).icon(() -> icon).displayItems((parameters, output) -> {
|
|
||||||
for (RegistryObject<Item> object : ITEMS.getEntries()) {
|
|
||||||
output.accept(object.get());
|
|
||||||
}
|
|
||||||
}).build());
|
|
||||||
|
|
||||||
this.registry.ITEMS.put(tab, this.ITEMS);
|
|
||||||
return tab;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public enum RegistryEntryType {
|
|
||||||
BLOCK,
|
|
||||||
ITEM,
|
|
||||||
BLOCK_ENTITY
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class RegistryContainer implements Iterable<Pair<RegistryEntryType, Object>> {
|
|
||||||
private final Object[] values;
|
|
||||||
private final String id;
|
|
||||||
public RegistryContainer(String id) {
|
|
||||||
this.values = new Object[RegistryEntryType.values().length];
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object get(RegistryEntryType key) {
|
|
||||||
return values[key.ordinal()];
|
|
||||||
}
|
|
||||||
|
|
||||||
public RegistryObject<? extends BlockEntityType<? extends BlockEntity>> getEntity() {
|
|
||||||
return getG(RegistryEntryType.BLOCK_ENTITY);
|
|
||||||
}
|
|
||||||
|
|
||||||
public RegistryObject<? extends Block> getBlock() {
|
|
||||||
return getG(RegistryEntryType.BLOCK);
|
|
||||||
}
|
|
||||||
|
|
||||||
public RegistryObject<? extends Item> getItem() {
|
|
||||||
return getG(RegistryEntryType.ITEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> T getG(RegistryEntryType key) {
|
|
||||||
return (T) values[key.ordinal()];
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean containsKey(RegistryEntryType key) {
|
|
||||||
return values[key.ordinal()] != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int size() {
|
|
||||||
int count = 0;
|
|
||||||
for (Object v : values) {
|
|
||||||
if (v != null) count++;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Iterable<RegistryEntryType> keys() {
|
|
||||||
RegistryEntryType[] keys = RegistryEntryType.values();
|
|
||||||
Set<RegistryEntryType> result = EnumSet.noneOf(RegistryEntryType.class);
|
|
||||||
for (int i = 0; i < values.length; i++) {
|
|
||||||
if (values[i] != null) result.add(keys[i]);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RegistryContainer register(Consumer<RegistryContainer> consumer) {
|
|
||||||
consumer.accept(this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void put(RegistryEntryType key, Object value) {
|
|
||||||
values[key.ordinal()] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public RegistryContainer block(Supplier<Block> supplier) {
|
|
||||||
put(RegistryEntryType.BLOCK, supplier);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RegistryContainer entity(Supplier<BlockEntityType<? extends BlockEntity>> supplier) {
|
|
||||||
put(RegistryEntryType.BLOCK_ENTITY, supplier);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RegistryContainer item(Supplier<Item> supplier) {
|
|
||||||
put(RegistryEntryType.ITEM, supplier);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Iterator<Pair<RegistryEntryType, Object>> iterator() {
|
|
||||||
List<Pair<RegistryEntryType, Object>> list = new ObjectArrayList<>();
|
|
||||||
for (RegistryEntryType key : keys()) {
|
|
||||||
list.add(new ObjectObjectImmutablePair<>(key, get(key)));
|
|
||||||
}
|
|
||||||
return list.iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public RegistryContainer register(ModRegistry registry) {
|
|
||||||
if (containsKey(RegistryEntryType.BLOCK)) put(RegistryEntryType.BLOCK, registry.BLOCKS.register(id, (Supplier<? extends Block>) get(RegistryEntryType.BLOCK)));
|
|
||||||
if (containsKey(RegistryEntryType.BLOCK_ENTITY)) put(RegistryEntryType.BLOCK_ENTITY, registry.BLOCK_ENTITIES.register(id, (Supplier<? extends BlockEntityType<? extends BlockEntity>>) get(RegistryEntryType.BLOCK_ENTITY)));
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RegistryContainer register(TabBuilder builder) {
|
|
||||||
if (containsKey(RegistryEntryType.ITEM)) put(RegistryEntryType.ITEM, builder.ITEMS.register(id, (Supplier<? extends Item>) get(RegistryEntryType.ITEM)));
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RegistryContainer create(String id) {
|
|
||||||
return new RegistryContainer(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package io.p2vman.vmodextras.util;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class ReflectionUtil {
|
|
||||||
public static <T> @Nonnull Optional<T> createInstance(@Nonnull Class<T> cls) {
|
|
||||||
try {
|
|
||||||
return Optional.of(cls.getDeclaredConstructor().newInstance());
|
|
||||||
} catch (Throwable t) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package io.p2vman.vmodextras.util;
|
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
|
|
||||||
public class ResourceLocationUtil {
|
|
||||||
public static ResourceLocation fromNamespaceAndPath(String namespace, String path) {
|
|
||||||
return new ResourceLocation(namespace, path);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package io.p2vman.vmodextras.util;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.ModList;
|
|
||||||
|
|
||||||
public class Utils {
|
|
||||||
public static void executeIsModEnable(String mod, Runnable runnable) {
|
|
||||||
if (ModList.get().isLoaded(mod)) {
|
|
||||||
runnable.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void executeIsModDisable(String mod, Runnable runnable) {
|
|
||||||
if (!ModList.get().isLoaded(mod)) {
|
|
||||||
runnable.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void executeIsModsEnable(Runnable runnable, String... mods) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void executeIsModsDisable(Runnable runnable, String... mods) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package io.p2vman.vmodextras.util;
|
|
||||||
|
|
||||||
import org.valkyrienskies.core.api.ships.ServerShip;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class VsUtils {
|
|
||||||
public static <T> @Nonnull Optional<T> getOrCreateAttachment(@Nonnull ServerShip ship, @Nonnull Class<T> cls) {
|
|
||||||
T obj = ship.getAttachment(cls);
|
|
||||||
if (obj != null) {
|
|
||||||
return Optional.of(obj);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Optional<T> ob = ReflectionUtil.createInstance(cls);
|
|
||||||
ob.ifPresent((j) -> ship.saveAttachment(cls, j));
|
|
||||||
return ob;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
package space.eptaproject.vmodaddon;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class Config {
|
||||||
|
public static final ForgeConfigSpec COMMON_CONFIG;
|
||||||
|
public static final ForgeConfigSpec.ConfigValue<List<? extends String>> RESOURCE_LOCATION_LIST;
|
||||||
|
public static final ForgeConfigSpec.ConfigValue<String> RESOURCE_LOCATION;
|
||||||
|
|
||||||
|
public static List<ResourceLocation> parsedList = new ObjectArrayList<>();
|
||||||
|
public static ResourceLocation replace = Validator.RB;
|
||||||
|
|
||||||
|
static {
|
||||||
|
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
||||||
|
|
||||||
|
builder.push("Settings");
|
||||||
|
|
||||||
|
RESOURCE_LOCATION_LIST = builder
|
||||||
|
.comment("List of blocked blocks, format: 'modid:path'")
|
||||||
|
.defineListAllowEmpty(
|
||||||
|
"blocked",
|
||||||
|
List.of("minecraft:stone", "minecraft:diamond_block"),
|
||||||
|
obj -> obj instanceof String && ResourceLocation.isValidResourceLocation((String) obj)
|
||||||
|
);
|
||||||
|
|
||||||
|
RESOURCE_LOCATION = builder
|
||||||
|
.comment("replace to, format: 'modid:path'")
|
||||||
|
.define(
|
||||||
|
"replace",
|
||||||
|
Validator.RB.toString()
|
||||||
|
);
|
||||||
|
|
||||||
|
builder.pop();
|
||||||
|
COMMON_CONFIG = builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void bake() {
|
||||||
|
parsedList = RESOURCE_LOCATION_LIST.get().stream()
|
||||||
|
.map(s -> {
|
||||||
|
try {
|
||||||
|
return ResourceLocation.parse(s);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.toList();
|
||||||
|
try {
|
||||||
|
replace = ResourceLocation.parse(RESOURCE_LOCATION.get());
|
||||||
|
} catch (Exception e) {
|
||||||
|
replace = Validator.RB;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
2
src/main/java/io/p2vman/vmodextras/IValidator.java → src/main/java/space/eptaproject/vmodaddon/IValidator.java
Executable file → Normal file
2
src/main/java/io/p2vman/vmodextras/IValidator.java → src/main/java/space/eptaproject/vmodaddon/IValidator.java
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
||||||
package io.p2vman.vmodextras;
|
package space.eptaproject.vmodaddon;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
14
src/main/java/io/p2vman/vmodextras/Validator.java → src/main/java/space/eptaproject/vmodaddon/Validator.java
Executable file → Normal file
14
src/main/java/io/p2vman/vmodextras/Validator.java → src/main/java/space/eptaproject/vmodaddon/Validator.java
Executable file → Normal file
|
@ -1,19 +1,18 @@
|
||||||
package io.p2vman.vmodextras;
|
package space.eptaproject.vmodaddon;
|
||||||
|
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
import io.p2vman.vmodextras.util.ResourceLocationUtil;
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
public class Validator implements IValidator {
|
public class Validator implements IValidator {
|
||||||
public static final Logger LOGGER = LoggerFactory.getLogger("Validator");
|
public static final Logger LOGGER = Logger.getLogger("Validator");
|
||||||
public static ResourceLocation RB = ResourceLocationUtil.fromNamespaceAndPath(VmodExtras.MODID, "example_block");
|
public static ResourceLocation RB = ResourceLocation.fromNamespaceAndPath(Vmodaddon.MODID, "example_block");
|
||||||
|
|
||||||
public Validator() {
|
public Validator() {
|
||||||
|
|
||||||
|
@ -21,7 +20,8 @@ public class Validator implements IValidator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void valid(Block block, ResourceLocation location, CallbackInfoReturnable<BlockState> info) {
|
public void valid(Block block, ResourceLocation location, CallbackInfoReturnable<BlockState> info) {
|
||||||
if (Config.parsedList.contains(location) && Config.Schematic_Blocked_Blocks_Enable) {
|
LOGGER.info(location.toString());
|
||||||
|
if (Config.parsedList.contains(location)) {
|
||||||
Block replacement = ForgeRegistries.BLOCKS.getValue(Config.replace);
|
Block replacement = ForgeRegistries.BLOCKS.getValue(Config.replace);
|
||||||
if (replacement != null) {
|
if (replacement != null) {
|
||||||
info.setReturnValue(replacement.defaultBlockState());
|
info.setReturnValue(replacement.defaultBlockState());
|
|
@ -0,0 +1,57 @@
|
||||||
|
package space.eptaproject.vmodaddon;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
|
import net.minecraft.world.level.material.MapColor;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
|
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
// The value here should match an entry in the META-INF/mods.toml file
|
||||||
|
@Mod(Vmodaddon.MODID)
|
||||||
|
public class Vmodaddon {
|
||||||
|
|
||||||
|
public static final String MODID = "vmodaddon";
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
|
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||||
|
|
||||||
|
public static final RegistryObject<Block> EXAMPLE_BLOCK = BLOCKS.register("example_block", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
||||||
|
|
||||||
|
public Vmodaddon() {
|
||||||
|
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
|
|
||||||
|
modEventBus.addListener(this::commonSetup);
|
||||||
|
|
||||||
|
BLOCKS.register(modEventBus);
|
||||||
|
|
||||||
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.COMMON_CONFIG);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void commonSetup(final FMLCommonSetupEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
|
public static class ModConfigHandler {
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onConfigReload(ModConfigEvent event) {
|
||||||
|
if (event.getConfig().getSpec() == Config.COMMON_CONFIG) {
|
||||||
|
Config.bake();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package io.p2vman.vmodextras.mixins.vmod;
|
package space.eptaproject.vmodaddon.mixin;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.util.CrudeIncrementalIntIdentityHashBiMap;
|
import net.minecraft.util.CrudeIncrementalIntIdentityHashBiMap;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
@ -13,33 +12,29 @@ import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
import io.p2vman.vmodextras.IValidator;
|
import space.eptaproject.vmodaddon.IValidator;
|
||||||
import io.p2vman.vmodextras.Validator;
|
import space.eptaproject.vmodaddon.Validator;
|
||||||
|
|
||||||
@Mixin(BlockPaletteHashMapV1.class)
|
@Mixin(BlockPaletteHashMapV1.class)
|
||||||
public class BlockPaletteHashMapV1Mixin {
|
public class BlockPaletteHashMapV1Mixin {
|
||||||
@Unique
|
@Unique
|
||||||
public final IValidator vmodextras$validator = new Validator();
|
public final IValidator validator = new Validator();
|
||||||
|
|
||||||
@Shadow(remap = false)
|
@Shadow
|
||||||
private @Mutable CrudeIncrementalIntIdentityHashBiMap<BlockState> statePaletteMap;
|
private @Mutable CrudeIncrementalIntIdentityHashBiMap statePaletteMap;
|
||||||
|
|
||||||
@Inject(method = "fromId", at = @At("RETURN"), remap = false, cancellable = true)
|
@Inject(method = "fromId", at = @At("RETURN"), remap = false, cancellable = true)
|
||||||
private void vmodaddon$fromId(int id, CallbackInfoReturnable<BlockState> cir) {
|
private void aboba(int id, CallbackInfoReturnable<BlockState> cir) {
|
||||||
BlockState blockState = this.statePaletteMap.byId(id);
|
BlockState blockState = (BlockState)this.statePaletteMap.byId(id);
|
||||||
if (blockState == null || blockState.isAir()) {
|
|
||||||
|
if (blockState.isAir()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = blockState.getBlock();
|
Block block = blockState.getBlock();
|
||||||
|
|
||||||
ResourceLocation location = ForgeRegistries.BLOCKS.getKey(block);
|
|
||||||
CallbackInfoReturnable<BlockState> info = new CallbackInfoReturnable<>("blockstate-validator", true);
|
CallbackInfoReturnable<BlockState> info = new CallbackInfoReturnable<>("blockstate-validator", true);
|
||||||
try {
|
validator.valid(block, ForgeRegistries.BLOCKS.getKey(block), info);
|
||||||
vmodextras$validator.valid(block, location, info);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Validator.LOGGER.error("Error validating: {}", location, e);
|
|
||||||
}
|
|
||||||
if (info.isCancelled()) {
|
if (info.isCancelled()) {
|
||||||
cir.setReturnValue(info.getReturnValue());
|
cir.setReturnValue(info.getReturnValue());
|
||||||
cir.cancel();
|
cir.cancel();
|
|
@ -0,0 +1,33 @@
|
||||||
|
package space.eptaproject.vmodaddon.mixin;
|
||||||
|
|
||||||
|
import kotlin.jvm.functions.Function3;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.spaceeye.valkyrien_ship_schematics.interfaces.v1.IShipSchematicDataV1;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mixin(targets = "net.spaceeye.vmod.schematic.SchematicActionsQueue$SchemPlacementItem")
|
||||||
|
public class SchemPlacementItemMixin {
|
||||||
|
@Inject(method = "<init>", at = @At("RETURN"))
|
||||||
|
private void afterConstruct(ServerLevel level, ServerPlayer player, IShipSchematicDataV1 schematicV1, List shipsToCreate, Function3 postPlacementFn, CallbackInfo ci) {
|
||||||
|
//IBlockStatePalette palette = schematicV1.getBlockPalette();
|
||||||
|
//Map<Long, ChunkyBlockData<BlockItem>> blockData = schematicV1.getBlockData();
|
||||||
|
|
||||||
|
//for (Map.Entry<Long, ChunkyBlockData<BlockItem>> entry : blockData.entrySet()) {
|
||||||
|
// ChunkyBlockData<BlockItem> chunk_data = entry.getValue();
|
||||||
|
// chunk_data.getBlocks().forEach((a, b) -> {
|
||||||
|
// b.forEach((c, f) -> {
|
||||||
|
// BlockState state = palette.fromId(f.getPaletteId());
|
||||||
|
//
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1 @@
|
||||||
public net.spaceeye.vmod.schematic.SchematicActionsQueue$SchemPlacementItem
|
public net.spaceeye.vmod.schematic.SchematicActionsQueue$SchemPlacementItem
|
||||||
public net.spaceeye.vmod.schematic.SchematicActionsQueue$SchemPlacementItem placeChunk(Lnet/minecraft/server/level/ServerLevel;Ljava/util/Map;Lnet/spaceeye/valkyrien_ship_schematics/containers/v1/ChunkyBlockData;Lnet/spaceeye/valkyrien_ship_schematics/interfaces/IBlockStatePalette;Ljava/util/List;Lnet/spaceeye/vmod/utils/Vector3d;)V # placeChunk
|
|
||||||
public net.spaceeye.vmod.schematic.SchematicActionsQueue$SchemPlacementItem place(JJ)Ljava/lang/Boolean; # place
|
|
||||||
public org.valkyrienskies.core.impl.game.ships.ShipData persistentAttachedData # persistentAttachedData
|
|
||||||
public edn.stratodonut.drivebywire.wire.ShipWireNetworkManager <init>(JJLjava/lang/String;)V # ShipWireNetworkManager
|
|
||||||
public edn.stratodonut.drivebywire.wire.ShipWireNetworkManager <init>()V # ShipWireNetworkManager
|
|
|
@ -1,21 +1,63 @@
|
||||||
modLoader = "javafml"
|
# This is an example mods.toml file. It contains the data relating to the loading mods.
|
||||||
loaderVersion = "${loader_version_range}"
|
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
|
||||||
|
# The overall format is standard TOML format, v0.5.0.
|
||||||
|
# Note that there are a couple of TOML lists in this file.
|
||||||
|
# Find more information on toml format here: https://github.com/toml-lang/toml
|
||||||
|
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||||
|
modLoader = "javafml" #mandatory
|
||||||
|
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||||
|
loaderVersion = "${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||||
|
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
||||||
|
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
||||||
license = "${mod_license}"
|
license = "${mod_license}"
|
||||||
[[mods]]
|
# A URL to refer people to when problems occur with this mod
|
||||||
modId = "${mod_id}"
|
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
|
||||||
version = "${mod_version}"
|
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||||
displayName = "${mod_name}"
|
[[mods]] #mandatory
|
||||||
authors = "${mod_authors}"
|
# The modid of the mod
|
||||||
|
modId = "${mod_id}" #mandatory
|
||||||
|
# The version number of the mod
|
||||||
|
version = "${mod_version}" #mandatory
|
||||||
|
# A display name for the mod
|
||||||
|
displayName = "${mod_name}" #mandatory
|
||||||
|
# A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/
|
||||||
|
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
|
||||||
|
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||||
|
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
|
||||||
|
# A file name (in the root of the mod JAR) containing a logo for display
|
||||||
|
#logoFile="vmodaddon.png" #optional
|
||||||
|
# A text field displayed in the mod UI
|
||||||
|
#credits="Thanks for this example mod goes to Java" #optional
|
||||||
|
# A text field displayed in the mod UI
|
||||||
|
authors = "${mod_authors}" #optional
|
||||||
|
# Display Test controls the display for your mod in the server connection screen
|
||||||
|
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
|
||||||
|
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
|
||||||
|
# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component.
|
||||||
|
# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value.
|
||||||
|
# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself.
|
||||||
|
#displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional)
|
||||||
|
|
||||||
|
# The description text for the mod (multi line!) (#mandatory)
|
||||||
description = '''${mod_description}'''
|
description = '''${mod_description}'''
|
||||||
[[dependencies."${mod_id}"]]
|
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||||
modId = "forge"
|
[[dependencies."${mod_id}"]] #optional
|
||||||
mandatory = true
|
# the modid of the dependency
|
||||||
versionRange = "${forge_version_range}"
|
modId = "forge" #mandatory
|
||||||
|
# Does this dependency have to exist - if not, ordering below must be specified
|
||||||
|
mandatory = true #mandatory
|
||||||
|
# The version range of the dependency
|
||||||
|
versionRange = "${forge_version_range}" #mandatory
|
||||||
|
# An ordering relationship for the dependency - BEFORE or AFTER required if the dependency is not mandatory
|
||||||
|
# BEFORE - This mod is loaded BEFORE the dependency
|
||||||
|
# AFTER - This mod is loaded AFTER the dependency
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
|
||||||
|
side = "BOTH"# Here's another dependency
|
||||||
[[dependencies."${mod_id}"]]
|
[[dependencies."${mod_id}"]]
|
||||||
modId = "minecraft"
|
modId = "minecraft"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
|
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||||
versionRange = "${minecraft_version_range}"
|
versionRange = "${minecraft_version_range}"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
@ -23,13 +65,13 @@ side = "BOTH"
|
||||||
[[dependencies."${mod_id}"]]
|
[[dependencies."${mod_id}"]]
|
||||||
modId = "the_vmod"
|
modId = "the_vmod"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "${the_vmod_version}"
|
versionRange = "1.2.2"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
|
||||||
[[dependencies."${mod_id}"]]
|
[[dependencies."${mod_id}"]]
|
||||||
modId = "valkyrien_ship_schematics"
|
modId = "valkyrien_ship_schematics"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "${valkyrien_ship_schematics_version}"
|
versionRange = "1.0"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"variants": {
|
|
||||||
"": { "model": "vmodextras:block/compact_backup" }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"variants": {
|
|
||||||
"": { "model": "vmodextras:block/track_backup" }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"variants": {
|
|
||||||
"": { "model": "vmodextras:block/track_work_controller" }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"block.vmodextras.track_backup": "Track Backup",
|
|
||||||
"block.vmodextras.ship_void": "Ship Void"
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "block/cube_all",
|
|
||||||
"textures": {
|
|
||||||
"all": "vmodextras:block/compact_backup"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "block/cube_all",
|
|
||||||
"textures": {
|
|
||||||
"all": "vmodextras:block/track_backup"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "block/cube_all",
|
|
||||||
"textures": {
|
|
||||||
"all": "vmodextras:block/track_work_controller"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "block/cube_all",
|
|
||||||
"textures": {
|
|
||||||
"all": "vmodextras:block/compact_backup"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "block/cube_all",
|
|
||||||
"textures": {
|
|
||||||
"all": "vmodextras:block/track_backup"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "block/cube_all",
|
|
||||||
"textures": {
|
|
||||||
"all": "vmodextras:block/track_work_controller"
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 170 B |
Binary file not shown.
Before Width: | Height: | Size: 167 B |
Binary file not shown.
Before Width: | Height: | Size: 178 B |
|
@ -1,15 +0,0 @@
|
||||||
local lib = {}
|
|
||||||
|
|
||||||
lib.Controllers = {
|
|
||||||
SimpleWheel = 0;
|
|
||||||
PhysicsTrack = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
lib.ControllerInterface = {}
|
|
||||||
lib.ControllerInterface.__index = lib.ControllerInterface
|
|
||||||
|
|
||||||
function lib.ControllerInterface.new(val)
|
|
||||||
return setmetatable({ value = val }, lib.ControllerInterface)
|
|
||||||
end
|
|
||||||
|
|
||||||
return lib
|
|
|
@ -1,17 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"block": "vmodextras:ship_void",
|
|
||||||
"mass": 0.0,
|
|
||||||
"friction": 0.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"block": "vmodextras:track_backup",
|
|
||||||
"mass": 120.0,
|
|
||||||
"friction": 0.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"block": "vmodextras:compact_backup",
|
|
||||||
"mass": 120.0,
|
|
||||||
"friction": 0.0
|
|
||||||
}
|
|
||||||
]
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"minVersion": "0.8",
|
||||||
|
"package": "space.eptaproject.vmodaddon.mixin",
|
||||||
|
"compatibilityLevel": "JAVA_8",
|
||||||
|
"refmap": "vmodaddon.refmap.json",
|
||||||
|
"mixins": [
|
||||||
|
"BlockPaletteHashMapV1Mixin"
|
||||||
|
],
|
||||||
|
"client": [
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,26 +0,0 @@
|
||||||
{
|
|
||||||
"required": true,
|
|
||||||
"minVersion": "0.8",
|
|
||||||
"package": "io.p2vman.vmodextras.mixins",
|
|
||||||
"compatibilityLevel": "JAVA_8",
|
|
||||||
"refmap": "vmodextras.refmap.json",
|
|
||||||
"mixins": [
|
|
||||||
"vmod.BlockPaletteHashMapV1Mixin",
|
|
||||||
"vmod.TeleportShipWithConnectedKtMixin",
|
|
||||||
"vmod.ScaleModeMixin",
|
|
||||||
"trackwork.PhysicsTrackControllerAccessor",
|
|
||||||
"trackwork.PhysicsTrackControllerMixin",
|
|
||||||
"trackwork.SimpleWheelControllerAccessor",
|
|
||||||
"trackwork.SimpleWheelControllerMixin",
|
|
||||||
"create.LecternControllerBlockMixin",
|
|
||||||
"create_tweaked_controllers.TweakedLecternControllerBlockMixin",
|
|
||||||
"create.RedstoneLinkBlockMixin",
|
|
||||||
"create.LinkHandlerMixin"
|
|
||||||
],
|
|
||||||
"client": [
|
|
||||||
],
|
|
||||||
"injectors": {
|
|
||||||
"defaultRequire": 1
|
|
||||||
},
|
|
||||||
"plugin": "io.p2vman.vmodextras.mixin.MixinPlugin"
|
|
||||||
}
|
|
Loading…
Reference in New Issue