mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-10-27 12:36:24 -04:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d0baab2ba |
@@ -3,4 +3,3 @@
|
|||||||
# are changed when only line endings change.
|
# are changed when only line endings change.
|
||||||
src/generated/**/.cache/cache text eol=lf
|
src/generated/**/.cache/cache text eol=lf
|
||||||
src/generated/**/*.json text eol=lf
|
src/generated/**/*.json text eol=lf
|
||||||
CHANGELOG.md merge=union
|
|
||||||
+1
-5
@@ -21,8 +21,6 @@ build
|
|||||||
# other
|
# other
|
||||||
eclipse
|
eclipse
|
||||||
run
|
run
|
||||||
runClient
|
|
||||||
runServer
|
|
||||||
|
|
||||||
# Files from Forge MDK
|
# Files from Forge MDK
|
||||||
forge*changelog.txt
|
forge*changelog.txt
|
||||||
@@ -36,8 +34,6 @@ common/src/main/resources/assets/cobblemon/showdown
|
|||||||
*/generated/resources/*
|
*/generated/resources/*
|
||||||
/fabric/src/generated/resources/cobblemon-common.accesswidener
|
/fabric/src/generated/resources/cobblemon-common.accesswidener
|
||||||
/.ignored/
|
/.ignored/
|
||||||
common/.fabric
|
|
||||||
.kotlin/
|
|
||||||
|
|
||||||
# MacOS
|
# MacOS
|
||||||
.DS_Store
|
.DS_Store
|
||||||
+29
-150
@@ -1,185 +1,64 @@
|
|||||||
image: amazoncorretto:21
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- export GRADLE_USER_HOME=`pwd`/.gradle
|
- export GRADLE_USER_HOME=`pwd`/.gradle
|
||||||
|
|
||||||
# TODO add client reference test process, search for import com.cobblemon.mod.common.client
|
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- preprocessing
|
|
||||||
- packsquash
|
|
||||||
- replaceresources
|
|
||||||
- build
|
- build
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
check_assets_cache:
|
#TODO add client reference test process, search for import com.cobblemon.mod.common.client
|
||||||
stage: preprocessing
|
|
||||||
script:
|
|
||||||
- echo "Checking if cached hash matches current hash"
|
|
||||||
|
|
||||||
# Calculate the current hash
|
|
||||||
- find common/src/main/resources/assets common/src/main/resources/data -type f -exec sha256sum {} + | sort -k 2 | sha256sum > current_hash.txt
|
|
||||||
- echo "Current hash:"
|
|
||||||
- cat current_hash.txt
|
|
||||||
|
|
||||||
# Check for the existence of the previous hash
|
|
||||||
- if [[ -f assets_data_hash.txt ]]; then
|
|
||||||
echo "Previous cached hash found:";
|
|
||||||
cat assets_data_hash.txt;
|
|
||||||
if cmp -s assets_data_hash.txt current_hash.txt; then
|
|
||||||
echo "Hashes match, skipping PackSquash";
|
|
||||||
rm -f run_packsquash.flag || true;
|
|
||||||
else
|
|
||||||
echo "Hashes differ, PackSquash needed";
|
|
||||||
touch run_packsquash.flag;
|
|
||||||
fi;
|
|
||||||
else
|
|
||||||
echo "No cached hash found, marking PackSquash as required";
|
|
||||||
touch run_packsquash.flag;
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Save the current hash for future runs
|
|
||||||
- echo "Saving current hash to cache";
|
|
||||||
- cp current_hash.txt assets_data_hash.txt
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- current_hash.txt
|
|
||||||
- assets_data_hash.txt
|
|
||||||
- run_packsquash.flag
|
|
||||||
expire_in: 7 days
|
|
||||||
cache:
|
|
||||||
key: "cache-${CI_COMMIT_REF_NAME}"
|
|
||||||
paths:
|
|
||||||
- assets_data_hash.txt
|
|
||||||
- ./compressed_pack.zip
|
|
||||||
|
|
||||||
setup_resource_pack:
|
|
||||||
stage: preprocessing
|
|
||||||
script:
|
|
||||||
- echo "Setting up fake resource pack"
|
|
||||||
- mkdir ./fake_resource_pack
|
|
||||||
- cp -r common/src/main/resources/assets common/src/main/resources/data ./fake_resource_pack/
|
|
||||||
- echo '{"pack":{"pack_format":34,"description":"Fake Cobblemon Pack"}}' > ./fake_resource_pack/pack.mcmeta
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- ./fake_resource_pack/
|
|
||||||
expire_in: 7 days
|
|
||||||
|
|
||||||
setup_packsquash:
|
|
||||||
stage: preprocessing
|
|
||||||
script:
|
|
||||||
- echo "Installing wget & unzip"
|
|
||||||
- yum install -y wget unzip
|
|
||||||
- echo "Downloading PackSquash"
|
|
||||||
- wget https://github.com/ComunidadAylas/PackSquash/releases/download/v0.4.0/PackSquash.CLI.executable.x86_64-unknown-linux-musl.zip
|
|
||||||
- unzip PackSquash.CLI.executable.x86_64-unknown-linux-musl.zip -d ./packsquash_bin
|
|
||||||
- echo "Creating PackSquash options.toml"
|
|
||||||
- |
|
|
||||||
cat <<EOF > ./options.toml
|
|
||||||
pack_directory = "./fake_resource_pack/"
|
|
||||||
output_file_path = "./compressed_pack.zip"
|
|
||||||
zip_spec_conformance_level = "high"
|
|
||||||
['**/*?.ogg']
|
|
||||||
transcode_ogg = false
|
|
||||||
two_pass_vorbis_optimization_and_validation = false
|
|
||||||
sampling_frequency = 999999
|
|
||||||
empty_audio_optimization=false
|
|
||||||
EOF
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- ./packsquash_bin/
|
|
||||||
- ./options.toml
|
|
||||||
expire_in: 7 days
|
|
||||||
|
|
||||||
default:
|
|
||||||
artifacts:
|
|
||||||
expire_in: 7 days
|
|
||||||
|
|
||||||
run_packsquash:
|
|
||||||
stage: packsquash
|
|
||||||
dependencies:
|
|
||||||
- check_assets_cache
|
|
||||||
- setup_resource_pack
|
|
||||||
- setup_packsquash
|
|
||||||
script:
|
|
||||||
- ls -l
|
|
||||||
- if [[ ! -f ./compressed_pack.zip || -f run_packsquash.flag ]]; then
|
|
||||||
echo "Running PackSquash";
|
|
||||||
chmod +x ./packsquash_bin/packsquash;
|
|
||||||
./packsquash_bin/packsquash ./options.toml;
|
|
||||||
else
|
|
||||||
echo "Skipping PackSquash; no changes detected and compressed pack exists";
|
|
||||||
fi
|
|
||||||
cache:
|
|
||||||
key: "cache-${CI_COMMIT_REF_NAME}"
|
|
||||||
policy: pull-push
|
|
||||||
paths:
|
|
||||||
- assets_data_hash.txt
|
|
||||||
- ./compressed_pack.zip
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- ./compressed_pack.zip
|
|
||||||
|
|
||||||
replace_resources:
|
|
||||||
stage: replaceresources
|
|
||||||
dependencies:
|
|
||||||
- run_packsquash
|
|
||||||
script:
|
|
||||||
- echo "Installing unzip"
|
|
||||||
- yum install -y unzip
|
|
||||||
|
|
||||||
- echo "Unzipping compressed pack"
|
|
||||||
- mkdir temp_unpack
|
|
||||||
- unzip ./compressed_pack.zip -d temp_unpack
|
|
||||||
|
|
||||||
- echo "Removing original assets and data"
|
|
||||||
- rm -rf common/src/main/resources/assets
|
|
||||||
- rm -rf common/src/main/resources/data
|
|
||||||
|
|
||||||
- echo "Replacing assets and data"
|
|
||||||
- mv temp_unpack/assets common/src/main/resources/
|
|
||||||
- mv temp_unpack/data common/src/main/resources/
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- common/src/main/resources/
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
dependencies:
|
only:
|
||||||
- replace_resources
|
- branches@cable-mc/cobblemon
|
||||||
script:
|
script:
|
||||||
- export GRADLE_OPTS="-Xmx4G -Xms4G"
|
- export GRADLE_OPTS="-Xmx4G -Xms4G"
|
||||||
- chmod +x ./gradlew
|
- chmod +x ./gradlew
|
||||||
- ./gradlew build
|
- ./gradlew build
|
||||||
artifacts:
|
cache:
|
||||||
|
key: "$CI_COMMIT_REF_NAME"
|
||||||
|
policy: push
|
||||||
paths:
|
paths:
|
||||||
- neoforge/build/libs
|
- forge/build/libs
|
||||||
- fabric/build/libs
|
- fabric/build/libs
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
dependencies:
|
dependencies:
|
||||||
- build
|
- build
|
||||||
|
cache:
|
||||||
|
key: "CI_COMMIT_REF_NAME"
|
||||||
|
policy: pull
|
||||||
|
paths:
|
||||||
|
- forge/build/libs/*.jar
|
||||||
|
- fabric/build/libs/*.jar
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_PROJECT_PATH == "cable-mc/cobblemon" && $CI_COMMIT_BRANCH == "main"'
|
- if: '$CI_COMMIT_BRANCH == "main"'
|
||||||
script:
|
script:
|
||||||
- export GRADLE_OPTS="-Xmx4G -Xms4G"
|
- export GRADLE_OPTS="-Xmx4G -Xms4G"
|
||||||
- chmod +x ./gradlew
|
- chmod +x ./gradlew
|
||||||
- ./gradlew publish
|
- ./gradlew publish
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- neoforge/build/libs/*.jar
|
|
||||||
- fabric/build/libs/*.jar
|
|
||||||
|
|
||||||
deploy_artifacts:
|
# Separate step to deploy the artifacts, save Norry the headache of keeping even more shit around
|
||||||
|
deploy:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
dependencies:
|
dependencies:
|
||||||
- build
|
- build
|
||||||
script:
|
when: manual
|
||||||
|
cache:
|
||||||
|
key: "$CI_COMMIT_REF_NAME"
|
||||||
|
policy: pull
|
||||||
|
paths:
|
||||||
|
- forge/build/libs/*.jar
|
||||||
|
- fabric/build/libs/*.jar
|
||||||
|
script:
|
||||||
- echo "Collecting artifacts..."
|
- echo "Collecting artifacts..."
|
||||||
- find neoforge/build/libs/ -type f -name "*.jar" | grep -vE "dev-shadow|sources|javadoc" | xargs -I {} mv {} ./
|
- mv forge/build/libs/*+*.jar ./
|
||||||
- find fabric/build/libs/ -type f -name "*.jar" | grep -vE "dev-shadow|sources|javadoc" | xargs -I {} mv {} ./
|
- mv fabric/build/libs/*+*.jar ./
|
||||||
- for f in *.jar; do mv "$f" "$(echo "$f" | sed s/+/b$CI_PIPELINE_IID+/)"; done
|
- for f in *.jar; do mv "$f" "$(echo "$f" | sed s/+/b$CI_PIPELINE_IID+/)"; done
|
||||||
artifacts:
|
artifacts:
|
||||||
|
expire_in: 28 days
|
||||||
paths:
|
paths:
|
||||||
- ./*.jar
|
- ./*.jar
|
||||||
|
# - forge/build/libs/*+*.jar
|
||||||
|
# - fabric/build/libs/*+*.jar
|
||||||
|
|||||||
+133
-953
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
|||||||
These are assets that may be used in the future, but can't be put in tFheir respective folders at the moment for some reason or another
|
|
||||||
@@ -1,27 +1,21 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("java-gradle-plugin")
|
`kotlin-dsl`
|
||||||
kotlin("jvm") version "2.1.0"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
maven("https://maven.architectury.dev/")
|
maven("https://maven.architectury.dev/")
|
||||||
maven("https://maven.fabricmc.net/")
|
maven("https://maven.fabricmc.net/")
|
||||||
|
maven("https://maven.minecraftforge.net/")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("net.neoforged:moddev-gradle:2.0.75")
|
implementation(libs.kotlin)
|
||||||
implementation("dev.architectury:at:1.0.1")
|
implementation(libs.licenser)
|
||||||
implementation("net.fabricmc:access-widener:2.1.0")
|
implementation(libs.shadow)
|
||||||
}
|
implementation(libs.loom)
|
||||||
|
implementation(libs.architecturyPlugin)
|
||||||
|
|
||||||
gradlePlugin {
|
implementation(libs.blossom)
|
||||||
plugins {
|
implementation(libs.ideaExt)
|
||||||
create("cobblemongradle") {
|
|
||||||
id = "com.cobblemon.gradle"
|
|
||||||
implementationClass = "com.cobblemon.gradle.CobblemonGradle"
|
|
||||||
version = "1.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
dependencyResolutionManagement {
|
import ca.stellardrift.build.configurate.ConfigFormats
|
||||||
versionCatalogs {
|
import ca.stellardrift.build.configurate.catalog.PolyglotVersionCatalogExtension
|
||||||
create("libs") {
|
|
||||||
from(files("../gradle/libs.versions.toml"))
|
plugins {
|
||||||
}
|
id("ca.stellardrift.polyglot-version-catalogs") version "5.0.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extensions.configure<PolyglotVersionCatalogExtension> {
|
||||||
|
from(ConfigFormats.YAML, file("../gradle/libs.versions.yml"))
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* * Copyright (C) 2023 Cobblemon Contributors
|
||||||
|
* *
|
||||||
|
* * This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* * License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* * file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
|
val accessWidenerFile = "src/main/resources/cobblemon-common.accesswidener"
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
java
|
||||||
|
`java-library`
|
||||||
|
id("org.cadixdev.licenser")
|
||||||
|
id("dev.architectury.loom")
|
||||||
|
id("architectury-plugin")
|
||||||
|
kotlin("jvm")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
//JEI
|
||||||
|
maven("https://maven.blamejared.com/")
|
||||||
|
maven("https://maven.tterrag.com/")
|
||||||
|
}
|
||||||
|
|
||||||
|
license {
|
||||||
|
header(rootProject.file("HEADER"))
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
}
|
||||||
|
|
||||||
|
architectury {
|
||||||
|
minecraft = project.property("mc_version").toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
loom {
|
||||||
|
silentMojangMappingsLicense()
|
||||||
|
accessWidenerPath.set(project(":common").file(ACCESS_WIDENER))
|
||||||
|
|
||||||
|
mixin {
|
||||||
|
defaultRefmapName.set("cobblemon-${project.name}-refmap.json")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
minecraft("net.minecraft:minecraft:${rootProject.property("mc_version")}")
|
||||||
|
mappings("net.fabricmc:yarn:${rootProject.property("yarn_version")}:v2")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
withType<JavaCompile> {
|
||||||
|
options.encoding = "UTF-8"
|
||||||
|
options.release.set(17)
|
||||||
|
}
|
||||||
|
|
||||||
|
withType<KotlinCompile> {
|
||||||
|
kotlinOptions.jvmTarget = "17"
|
||||||
|
}
|
||||||
|
|
||||||
|
withType<Jar> {
|
||||||
|
from(rootProject.file("LICENSE"))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
plugins {
|
||||||
|
id("cobblemon.base-conventions")
|
||||||
|
id("com.github.johnrengelman.shadow")
|
||||||
|
}
|
||||||
|
|
||||||
|
val bundle: Configuration by configurations.creating {
|
||||||
|
isCanBeConsumed = false
|
||||||
|
isCanBeResolved = true
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
|
||||||
|
jar {
|
||||||
|
archiveBaseName.set("Cobblemon-${project.name}")
|
||||||
|
archiveClassifier.set("dev-slim")
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowJar {
|
||||||
|
archiveClassifier.set("dev-shadow")
|
||||||
|
archiveBaseName.set("Cobblemon-${project.name}")
|
||||||
|
configurations = listOf(bundle)
|
||||||
|
mergeServiceFiles()
|
||||||
|
}
|
||||||
|
|
||||||
|
remapJar {
|
||||||
|
dependsOn(shadowJar)
|
||||||
|
inputFile.set(shadowJar.flatMap { it.archiveFile })
|
||||||
|
archiveBaseName.set("Cobblemon-${project.name}")
|
||||||
|
archiveVersion.set("${rootProject.version}")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+4
-4
@@ -1,9 +1,9 @@
|
|||||||
import utilities.VersionType
|
import extensions.VersionType
|
||||||
import utilities.writeVersion
|
import extensions.writeVersion
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("java")
|
java
|
||||||
id("java-library")
|
`java-library`
|
||||||
id("maven-publish")
|
id("maven-publish")
|
||||||
id("dev.architectury.loom")
|
id("dev.architectury.loom")
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
plugins {
|
||||||
|
`java-library`
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
val collectJars by registering(Copy::class) {
|
||||||
|
val tasks = subprojects.filter { it.path != ":common" }.map { it.tasks.named("remapJar") }
|
||||||
|
dependsOn(tasks)
|
||||||
|
|
||||||
|
from(tasks)
|
||||||
|
into(buildDir.resolve("libs"))
|
||||||
|
}
|
||||||
|
|
||||||
|
assemble {
|
||||||
|
dependsOn(collectJars)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Test> {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
package com.cobblemon.gradle
|
|
||||||
|
|
||||||
import com.cobblemon.gradle.extension.CobblemonGradleExtension
|
|
||||||
import com.cobblemon.gradle.extension.tasks.ConvertAccessWidenersTask
|
|
||||||
import com.cobblemon.gradle.extension.tasks.UnzipAccessWidenersTask
|
|
||||||
import net.neoforged.nfrtgradle.CreateMinecraftArtifacts
|
|
||||||
import org.gradle.api.Plugin
|
|
||||||
import org.gradle.api.Project
|
|
||||||
import org.gradle.api.attributes.LibraryElements
|
|
||||||
import org.gradle.language.jvm.tasks.ProcessResources
|
|
||||||
|
|
||||||
class CobblemonGradle : Plugin<Project> {
|
|
||||||
override fun apply(project: Project) {
|
|
||||||
val cobblemonExtension = project.extensions.create(
|
|
||||||
CobblemonGradleExtension.EXTENSION_NAME,
|
|
||||||
CobblemonGradleExtension::class.java
|
|
||||||
)
|
|
||||||
|
|
||||||
//This exists because all of
|
|
||||||
// - com.cobblemon:mod
|
|
||||||
// - com.cobblemon:mod-resources
|
|
||||||
// - com.cobblemon:accesswidener
|
|
||||||
//technically point to the same dependency (the :common project). To pick the proper artifact from that project
|
|
||||||
//we set attributes in that project and check for them here.
|
|
||||||
val accessWideners = project.configurations.register("accessWidener") { configuration ->
|
|
||||||
configuration.isCanBeConsumed = false
|
|
||||||
configuration.isCanBeResolved = true
|
|
||||||
configuration.isCanBeDeclared = true
|
|
||||||
configuration.attributes {
|
|
||||||
it.attribute(
|
|
||||||
LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE,
|
|
||||||
project.objects.named(LibraryElements::class.java, LibraryElements.OBJECTS)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val includeRootResources = project.configurations.register("includeRootResources") { configuration ->
|
|
||||||
configuration.isCanBeConsumed = false
|
|
||||||
configuration.isCanBeResolved = true
|
|
||||||
configuration.isCanBeDeclared = true
|
|
||||||
configuration.attributes {
|
|
||||||
it.attribute(
|
|
||||||
LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE,
|
|
||||||
project.objects.named(LibraryElements::class.java, LibraryElements.RESOURCES)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val unzipAwTask = project.tasks.register("unzipAccessWideners", UnzipAccessWidenersTask::class.java) {
|
|
||||||
it.accessWidenerZips = accessWideners.get()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
val convertAwTask = project.tasks.register(ConvertAccessWidenersTask.NAME, ConvertAccessWidenersTask::class.java) {
|
|
||||||
it.enabled = cobblemonExtension.convertAccessWideners
|
|
||||||
it.dependsOn(unzipAwTask)
|
|
||||||
it.accessWideners = project.files(unzipAwTask).plus(project.files(cobblemonExtension.additionalAccessWideners))
|
|
||||||
}
|
|
||||||
|
|
||||||
//Add root resources and access wideners to output jar
|
|
||||||
project.tasks.named("processResources", ProcessResources::class.java) { task ->
|
|
||||||
task.dependsOn(includeRootResources)
|
|
||||||
if (cobblemonExtension.convertAccessWideners) {
|
|
||||||
task.dependsOn(convertAwTask)
|
|
||||||
task.from(convertAwTask)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
task.dependsOn(unzipAwTask)
|
|
||||||
task.from(unzipAwTask)
|
|
||||||
}
|
|
||||||
task.doLast {
|
|
||||||
project.copy {
|
|
||||||
it.from(project.provider {
|
|
||||||
includeRootResources.get().resolve().map { project.zipTree(it) }
|
|
||||||
})
|
|
||||||
it.into(task.destinationDir)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
project.tasks.withType(CreateMinecraftArtifacts::class.java) {
|
|
||||||
it.dependsOn(convertAwTask)
|
|
||||||
it.accessTransformers.from(convertAwTask)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
package com.cobblemon.gradle.extension
|
|
||||||
|
|
||||||
import org.gradle.api.file.FileCollection
|
|
||||||
|
|
||||||
abstract class CobblemonGradleExtension {
|
|
||||||
var additionalAccessWideners: FileCollection? = null
|
|
||||||
var convertAccessWideners = true
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val EXTENSION_NAME = "cobblemon"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-82
@@ -1,82 +0,0 @@
|
|||||||
package com.cobblemon.gradle.extension.tasks
|
|
||||||
|
|
||||||
import dev.architectury.at.AccessChange
|
|
||||||
import dev.architectury.at.AccessTransform
|
|
||||||
import dev.architectury.at.AccessTransformSet
|
|
||||||
import dev.architectury.at.ModifierChange
|
|
||||||
import dev.architectury.at.io.AccessTransformFormats
|
|
||||||
import net.fabricmc.accesswidener.AccessWidenerReader
|
|
||||||
import net.fabricmc.accesswidener.AccessWidenerVisitor
|
|
||||||
import org.cadixdev.bombe.type.signature.MethodSignature
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.file.FileCollection
|
|
||||||
import org.gradle.api.tasks.InputFiles
|
|
||||||
import org.gradle.api.tasks.Internal
|
|
||||||
import org.gradle.api.tasks.OutputFiles
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
import java.io.Writer
|
|
||||||
import java.nio.file.Files
|
|
||||||
|
|
||||||
abstract class ConvertAccessWidenersTask : DefaultTask() {
|
|
||||||
abstract var accessWideners: FileCollection
|
|
||||||
@InputFiles get
|
|
||||||
|
|
||||||
@Internal
|
|
||||||
val accessTransformerDir = project.layout.buildDirectory.dir("access-transformers")
|
|
||||||
|
|
||||||
@OutputFiles
|
|
||||||
val accessTransformers = project.files ({
|
|
||||||
accessWideners.files.map {
|
|
||||||
accessTransformerDir.get().file(it.name.replace("accesswidener", "accesstransformer.cfg"))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
fun convertAccessWideners() {
|
|
||||||
accessWideners.files.forEach { file ->
|
|
||||||
val awFile = Files.newBufferedReader(file.toPath())
|
|
||||||
val result = AccessTransformSet.create();
|
|
||||||
|
|
||||||
AccessWidenerReader(object : AccessWidenerVisitor {
|
|
||||||
override fun visitClass(name: String, access: AccessWidenerReader.AccessType, transitive: Boolean) {
|
|
||||||
result.getOrCreateClass(name).merge(toAt(access));
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitMethod(owner: String, name: String, descriptor: String, access: AccessWidenerReader.AccessType, transitive: Boolean) {
|
|
||||||
result.getOrCreateClass(owner).mergeMethod(MethodSignature.of(name, descriptor), toAt(access));
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitField(owner: String, name: String, descriptor: String, access: AccessWidenerReader.AccessType, transitive: Boolean) {
|
|
||||||
result.getOrCreateClass(owner).mergeField(name, toAt(access));
|
|
||||||
}
|
|
||||||
}).read(awFile)
|
|
||||||
|
|
||||||
val outputFile = accessTransformerDir.get().file(
|
|
||||||
file.name.replace("accesswidener", "accesstransformer.cfg")
|
|
||||||
)
|
|
||||||
var outputWriter: Writer? = null
|
|
||||||
try {
|
|
||||||
outputWriter = outputFile.asFile.writer()
|
|
||||||
AccessTransformFormats.FML.write(outputWriter, result)
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
outputWriter?.flush()
|
|
||||||
outputWriter?.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun toAt(access: AccessWidenerReader.AccessType): AccessTransform {
|
|
||||||
return when (access) {
|
|
||||||
AccessWidenerReader.AccessType.ACCESSIBLE -> AccessTransform.of(AccessChange.PUBLIC)
|
|
||||||
AccessWidenerReader.AccessType.EXTENDABLE, AccessWidenerReader.AccessType.MUTABLE -> AccessTransform.of(
|
|
||||||
AccessChange.PUBLIC,
|
|
||||||
ModifierChange.REMOVE
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
companion object {
|
|
||||||
const val NAME = "convertAccessWideners"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-33
@@ -1,33 +0,0 @@
|
|||||||
package com.cobblemon.gradle.extension.tasks
|
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
|
||||||
import org.gradle.api.Task
|
|
||||||
import org.gradle.api.file.FileCollection
|
|
||||||
import org.gradle.api.tasks.InputFiles
|
|
||||||
import org.gradle.api.tasks.Internal
|
|
||||||
import org.gradle.api.tasks.OutputFile
|
|
||||||
import org.gradle.api.tasks.OutputFiles
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
|
||||||
|
|
||||||
abstract class UnzipAccessWidenersTask : DefaultTask() {
|
|
||||||
abstract var accessWidenerZips: FileCollection
|
|
||||||
@InputFiles get
|
|
||||||
|
|
||||||
@OutputFiles
|
|
||||||
val outputFiles = project.provider {
|
|
||||||
project.files(accessWidenerZips.flatMap { zip ->
|
|
||||||
project.zipTree(zip).files.map { OUTPUT_DIR.get().file(it.name) }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
@Internal
|
|
||||||
val OUTPUT_DIR = project.layout.buildDirectory.dir("cobblemon-working/access-wideners")
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
fun run() {
|
|
||||||
project.copy {
|
|
||||||
it.from(accessWidenerZips.map(project::zipTree))
|
|
||||||
it.into(OUTPUT_DIR)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-1
@@ -1,3 +1,2 @@
|
|||||||
package utilities
|
|
||||||
|
|
||||||
const val ACCESS_WIDENER = "src/main/resources/cobblemon-common.accesswidener"
|
const val ACCESS_WIDENER = "src/main/resources/cobblemon-common.accesswidener"
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package utilities
|
package extensions
|
||||||
|
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
|
|
||||||
+5
-6
@@ -1,14 +1,13 @@
|
|||||||
plugins {
|
plugins {
|
||||||
//id("cobblemon.root-conventions")
|
base
|
||||||
id ("net.nemerosa.versioning") version "3.1.0"
|
id("cobblemon.root-conventions")
|
||||||
|
id ("net.nemerosa.versioning") version "2.8.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
group = "com.cobblemon.mod"
|
||||||
version = "${project.property("mod_version")}+${project.property("mc_version")}"
|
version = "${project.property("mod_version")}+${project.property("mc_version")}"
|
||||||
|
|
||||||
val isSnapshot = project.property("snapshot")?.equals("true") ?: false
|
val isSnapshot = project.property("snapshot")?.equals("true") ?: false
|
||||||
/*
|
|
||||||
if (isSnapshot) {
|
if (isSnapshot) {
|
||||||
val fixedBranchName = versioning.info.branch.substringAfter("/")
|
version = "$version-${versioning.info.branch}-${versioning.info.build}"
|
||||||
version = "$version-${fixedBranchName}-${versioning.info.build}"
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
+62
-94
@@ -1,102 +1,72 @@
|
|||||||
|
import extensions.isSnapshot
|
||||||
|
import extensions.version
|
||||||
|
import java.time.OffsetDateTime
|
||||||
|
import java.time.ZoneOffset
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* * Copyright (C) 2023 Cobblemon Contributors
|
||||||
|
* *
|
||||||
|
* * This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* * License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* * file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "2.1.0"
|
id("cobblemon.base-conventions")
|
||||||
id ("net.neoforged.moddev") version "2.0.75"
|
id("cobblemon.publish-conventions")
|
||||||
id("net.kyori.blossom") version "2.1.0"
|
|
||||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
id("net.kyori.blossom")
|
||||||
id("com.cobblemon.gradle")
|
id("org.jetbrains.gradle.plugin.idea-ext")
|
||||||
|
id ("net.nemerosa.versioning") version "2.8.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
cobblemon {
|
architectury {
|
||||||
additionalAccessWideners = files(sourceSets.main.get().resources).filter { it.extension == "accesswidener" }
|
common("forge", "fabric")
|
||||||
}
|
|
||||||
|
|
||||||
val rootResources = configurations.create("rootResources") {
|
|
||||||
isCanBeConsumed = true
|
|
||||||
isCanBeResolved = false
|
|
||||||
attributes {
|
|
||||||
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.RESOURCES))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val accessWidenerExport = configurations.create("accessWidenerExport") {
|
|
||||||
isCanBeConsumed = true
|
|
||||||
isCanBeResolved = false
|
|
||||||
attributes {
|
|
||||||
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.OBJECTS))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.processResources {
|
|
||||||
exclude("*.accesswidener")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.create<Zip>("zipResources") {
|
|
||||||
dependsOn("processResources")
|
|
||||||
from(tasks.processResources.get().destinationDir)
|
|
||||||
this.archiveBaseName = "mod-resources"
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.create<Zip>("zipAccessWideners") {
|
|
||||||
from(sourceSets.main.get().resources)
|
|
||||||
include("*.accesswidener")
|
|
||||||
this.archiveBaseName = "mod-accesswideners"
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.jar {
|
|
||||||
archiveBaseName = "mod"
|
|
||||||
manifest {
|
|
||||||
attributes(mapOf("FMLModType" to "GAMELIBRARY"))
|
|
||||||
}
|
|
||||||
exclude {
|
|
||||||
it.file in tasks.processResources.get().outputs.files
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.assemble {
|
|
||||||
dependsOn(tasks.named("zipResources"))
|
|
||||||
dependsOn(tasks.named("zipAccessWideners"))
|
|
||||||
}
|
|
||||||
|
|
||||||
artifacts {
|
|
||||||
add("rootResources", tasks.getByName<Zip>("zipResources"))
|
|
||||||
add("accessWidenerExport", tasks.getByName("zipAccessWideners"))
|
|
||||||
}
|
|
||||||
|
|
||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
gradlePluginPortal()
|
|
||||||
maven("https://maven.architectury.dev/")
|
|
||||||
maven("https://maven.fabricmc.net/")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
maven(url = "${rootProject.projectDir}/deps")
|
||||||
maven("https://maven.fabricmc.net/")
|
maven(url = "https://api.modrinth.com/maven")
|
||||||
maven("https://maven.blamejared.com/")
|
mavenLocal()
|
||||||
maven("https://api.modrinth.com/maven")
|
|
||||||
maven(url = "../deps")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(libs.bundles.mongo)
|
implementation(libs.stdlib)
|
||||||
compileOnly(libs.bundles.kotlin)
|
implementation(libs.reflect)
|
||||||
compileOnly(libs.molang)
|
|
||||||
compileOnly(libs.graal)
|
modImplementation(libs.fabricLoader)
|
||||||
compileOnly(libs.jei.api)
|
//Flywheel has no common dep so just pick one and don't use any platform specific code in common
|
||||||
compileOnly(libs.bundles.fabric.integrations.compileOnly) {
|
// modCompileOnly(libs.flywheelFabric)
|
||||||
isTransitive = false
|
modApi(libs.molang)
|
||||||
}
|
compileOnlyApi(libs.jeiApi)
|
||||||
compileOnly("net.fabricmc:sponge-mixin:0.15.5+mixin.0.8.7")
|
modCompileOnly(libs.adornFabric)
|
||||||
compileOnly("io.github.llamalad7:mixinextras-fabric:0.4.1")
|
modCompileOnly(libs.lambDynamicLights) { isTransitive = false }
|
||||||
testImplementation(libs.bundles.unitTesting)
|
|
||||||
|
// For Showdown
|
||||||
|
modCompileOnly(libs.graal)
|
||||||
|
|
||||||
|
//shadowCommon group: 'commons-io', name: 'commons-io', version: '2.6'
|
||||||
|
|
||||||
|
// For datastore
|
||||||
|
modCompileOnly(libs.mongoDriverCore)
|
||||||
|
modCompileOnly(libs.mongoDriverSync)
|
||||||
|
|
||||||
|
testImplementation(libs.fabricJunit)
|
||||||
|
testImplementation(libs.junitParams)
|
||||||
|
testImplementation(libs.mockito)
|
||||||
|
testImplementation(libs.mockk)
|
||||||
|
testImplementation(libs.classgraph)
|
||||||
}
|
}
|
||||||
|
|
||||||
neoForge {
|
tasks.withType<Test> {
|
||||||
neoFormVersion = "1.21.1-20240808.144430"
|
useJUnitPlatform()
|
||||||
interfaceInjectionData.from("src/main/resources/interfaces.json")
|
testLogging {
|
||||||
validateAccessTransformers = true
|
setEvents(listOf("failed"))
|
||||||
|
setExceptionFormat("full")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -106,7 +76,7 @@ sourceSets {
|
|||||||
fun generateLicenseHeader() : String {
|
fun generateLicenseHeader() : String {
|
||||||
val builder = StringBuilder()
|
val builder = StringBuilder()
|
||||||
builder.append("/*\n")
|
builder.append("/*\n")
|
||||||
project.projectDir.parentFile.resolve("HEADER").forEachLine {
|
rootProject.file("HEADER").forEachLine {
|
||||||
if(it.isEmpty()) {
|
if(it.isEmpty()) {
|
||||||
builder.append(" *").append("\n")
|
builder.append(" *").append("\n")
|
||||||
} else {
|
} else {
|
||||||
@@ -119,15 +89,13 @@ sourceSets {
|
|||||||
|
|
||||||
property("license", generateLicenseHeader())
|
property("license", generateLicenseHeader())
|
||||||
property("modid", "cobblemon")
|
property("modid", "cobblemon")
|
||||||
property("version", project.version as String)
|
property("version", project.version())
|
||||||
property("isSnapshot", "true")
|
property("isSnapshot", if(rootProject.isSnapshot()) "true" else "false")
|
||||||
/*
|
|
||||||
property("gitCommit", versioning.info.commit)
|
property("gitCommit", versioning.info.commit)
|
||||||
property("branch", versioning.info.branch)
|
property("branch", versioning.info.branch)
|
||||||
System.getProperty("buildNumber")?.let { property("buildNumber", it) }
|
System.getProperty("buildNumber")?.let { property("buildNumber", it) }
|
||||||
property("timestamp", OffsetDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ofPattern("MM/dd/yyyy hh:mm:ss")) + " UTC")
|
property("timestamp", OffsetDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ofPattern("MM/dd/yyyy hh:mm:ss")) + " UTC")
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,97 +0,0 @@
|
|||||||
import java.time.OffsetDateTime
|
|
||||||
import java.time.ZoneOffset
|
|
||||||
import java.time.format.DateTimeFormatter
|
|
||||||
import utilities.isSnapshot
|
|
||||||
import utilities.version
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* * Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
* *
|
|
||||||
* * This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* * file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("cobblemon.base-conventions")
|
|
||||||
id("cobblemon.publish-conventions")
|
|
||||||
|
|
||||||
id("net.kyori.blossom")
|
|
||||||
id("org.jetbrains.gradle.plugin.idea-ext")
|
|
||||||
id("net.nemerosa.versioning") version "3.1.0"
|
|
||||||
}
|
|
||||||
|
|
||||||
architectury {
|
|
||||||
common("neoforge", "fabric")
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven(url = "${rootProject.projectDir}/deps")
|
|
||||||
maven(url = "https://api.modrinth.com/maven")
|
|
||||||
maven(url = "https://maven.neoforged.net/releases")
|
|
||||||
mavenLocal()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation(libs.bundles.kotlin)
|
|
||||||
modImplementation(libs.fabric.loader)
|
|
||||||
modApi(libs.molang)
|
|
||||||
|
|
||||||
// Integrations
|
|
||||||
compileOnlyApi(libs.jei.api)
|
|
||||||
modCompileOnly(libs.bundles.fabric.integrations.compileOnly) {
|
|
||||||
isTransitive = false
|
|
||||||
}
|
|
||||||
// Flywheel has no common dep so just pick one and don't use any platform specific code in common
|
|
||||||
// modCompileOnly(libs.flywheelFabric)
|
|
||||||
|
|
||||||
// Showdown
|
|
||||||
modCompileOnly(libs.graal)
|
|
||||||
|
|
||||||
// Data Storage
|
|
||||||
modCompileOnly(libs.bundles.mongo)
|
|
||||||
|
|
||||||
// Unit Testing
|
|
||||||
testImplementation(libs.bundles.unitTesting)
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<Test> {
|
|
||||||
useJUnitPlatform()
|
|
||||||
testLogging {
|
|
||||||
setEvents(listOf("failed"))
|
|
||||||
setExceptionFormat("full")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
main {
|
|
||||||
blossom {
|
|
||||||
kotlinSources {
|
|
||||||
fun generateLicenseHeader() : String {
|
|
||||||
val builder = StringBuilder()
|
|
||||||
builder.append("/*\n")
|
|
||||||
rootProject.file("HEADER").forEachLine {
|
|
||||||
if(it.isEmpty()) {
|
|
||||||
builder.append(" *").append("\n")
|
|
||||||
} else {
|
|
||||||
builder.append(" * ").append(it).append("\n")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder.append(" */").append("\n").toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
property("license", generateLicenseHeader())
|
|
||||||
property("modid", "cobblemon")
|
|
||||||
property("version", project.version())
|
|
||||||
property("isSnapshot", if(rootProject.isSnapshot()) "true" else "false")
|
|
||||||
property("gitCommit", versioning.info.commit)
|
|
||||||
property("branch", versioning.info.branch)
|
|
||||||
System.getProperty("buildNumber")?.let { property("buildNumber", it) }
|
|
||||||
property("timestamp", OffsetDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ofPattern("MM/dd/yyyy hh:mm:ss")) + " UTC")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
[versions]
|
|
||||||
# Kotlin
|
|
||||||
kotlin = "2.0.0"
|
|
||||||
|
|
||||||
# Plugins
|
|
||||||
licenser = "0.6.1"
|
|
||||||
shadow = "8.1.1"
|
|
||||||
blossom = "2.1.0"
|
|
||||||
idea-ext = "1.1.7"
|
|
||||||
|
|
||||||
# Loom
|
|
||||||
loom = "1.7-SNAPSHOT"
|
|
||||||
architectury-plugin = "3.4-SNAPSHOT"
|
|
||||||
|
|
||||||
# Common
|
|
||||||
molang = "1.1.18"
|
|
||||||
graal = "22.3.0"
|
|
||||||
icu4j = "71.1"
|
|
||||||
jei-api = "19.8.2.99"
|
|
||||||
|
|
||||||
# Fabric
|
|
||||||
fabric-loader = "0.16.5"
|
|
||||||
fabric-api = "0.104.0+1.21.1"
|
|
||||||
fabric-kotlin = "1.11.0+kotlin.2.0.0"
|
|
||||||
fabric-permissions-api = "0.2-SNAPSHOT"
|
|
||||||
lambDynamicLights = "3.0.1+1.21.1"
|
|
||||||
debugutils-fabric = "1.21-1.0.6-fabric"
|
|
||||||
|
|
||||||
# NeoForge
|
|
||||||
neoforge = "21.1.66"
|
|
||||||
neo-kotlin-for-forge = "5.5.0"
|
|
||||||
debugutils-forge = "1.21-1.0.6-neoforge"
|
|
||||||
|
|
||||||
# Data Storage
|
|
||||||
mongo = "4.10.2"
|
|
||||||
|
|
||||||
# Testing
|
|
||||||
junit = "5.9.0"
|
|
||||||
mockito = "5.2.0"
|
|
||||||
mockk = "1.12.1"
|
|
||||||
classgraph = "4.8.153"
|
|
||||||
|
|
||||||
[libraries]
|
|
||||||
# General Buildscript Plugins
|
|
||||||
kotlin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
|
|
||||||
loom = { group = "dev.architectury", name = "architectury-loom", version.ref = "loom" }
|
|
||||||
architectury = { group = "architectury-plugin", name = "architectury-plugin.gradle.plugin", version.ref = "architectury-plugin" }
|
|
||||||
shadow = { group = "com.github.johnrengelman", name = "shadow", version.ref = "shadow" }
|
|
||||||
blossom = { group = "net.kyori", name = "blossom", version.ref = "blossom" }
|
|
||||||
ideaExt = { group = "org.jetbrains.gradle.plugin.idea-ext", name = "org.jetbrains.gradle.plugin.idea-ext.gradle.plugin", version.ref = "idea-ext"}
|
|
||||||
licenser = { group = "gradle.plugin.org.cadixdev.gradle", name = "licenser", version.ref = "licenser" }
|
|
||||||
|
|
||||||
# Kotlin
|
|
||||||
kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlin" }
|
|
||||||
kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" }
|
|
||||||
|
|
||||||
# Common
|
|
||||||
jei-api = { group = "mezz.jei", name = "jei-1.21-common-api", version.ref = "jei-api"}
|
|
||||||
molang = { group = "local.com.bedrockk", name = "molang", version.ref = "molang" }
|
|
||||||
graal = { group = "org.graalvm.js", name = "js", version.ref = "graal" }
|
|
||||||
icu4j = { group = "com.ibm.icu", name = "icu4j", version.ref = "icu4j" }
|
|
||||||
|
|
||||||
# Fabric
|
|
||||||
fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabric-loader" }
|
|
||||||
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric-api" }
|
|
||||||
fabric-kotlin = { group = "net.fabricmc", name = "fabric-language-kotlin", version.ref = "fabric-kotlin" }
|
|
||||||
fabric-permissions = { group = "me.lucko", name = "fabric-permissions-api", version.ref = "fabric-permissions-api" }
|
|
||||||
adorn-fabric = { group = "maven.modrinth", name = "adorn", version = "6.0.0-neoforge"}
|
|
||||||
lambDynamicLights = { group = "maven.modrinth", name = "lambdynamiclights", version.ref = "lambDynamicLights"}
|
|
||||||
jei-api-fabric = { group = "mezz.jei", name = "jei-1.21-fabric-api", version.ref = "jei-api" }
|
|
||||||
jei-fabric = { group = "mezz.jei", name = "jei-1.21-fabric", version.ref = "jei-api"}
|
|
||||||
fabric-debugutils = { group = "maven.modrinth", name = "debugutils", version.ref = "debugutils-fabric"}
|
|
||||||
|
|
||||||
# NeoForge
|
|
||||||
neoforge = { group = "net.neoforged", name = "neoforge", version.ref = "neoforge" }
|
|
||||||
neo-kotlin-forge = { group = "thedarkcolour", name = "kotlinforforge-neoforge", version.ref = "neo-kotlin-for-forge" }
|
|
||||||
neoforge-debugutils = { group = "maven.modrinth", name = "debugutils", version.ref = "debugutils-forge"}
|
|
||||||
|
|
||||||
# Data Storage
|
|
||||||
mongo-driver-core = { group = "org.mongodb", name = "mongodb-driver-core", version.ref = "mongo" }
|
|
||||||
mongo-driver-sync = { group = "org.mongodb", name = "mongodb-driver-sync", version.ref = "mongo" }
|
|
||||||
|
|
||||||
# Testing
|
|
||||||
junit = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junit" }
|
|
||||||
mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockito" }
|
|
||||||
mock-kotlin = { group = "io.mockk", name = "mockk", version.ref = "mockk" }
|
|
||||||
classgraph = { group = "io.github.classgraph", name = "classgraph", version.ref = "classgraph" }
|
|
||||||
|
|
||||||
[bundles]
|
|
||||||
kotlin = [ "kotlin-stdlib", "kotlin-reflect" ]
|
|
||||||
fabric = [ "fabric-kotlin", "fabric-permissions" ]
|
|
||||||
fabric-integrations-compileOnly = [ "adorn-fabric", "lambDynamicLights", "jei-api-fabric" ]
|
|
||||||
fabric-integrations-runtimeOnly = [ "jei-fabric" ]
|
|
||||||
mongo = [ "mongo-driver-core", "mongo-driver-sync" ]
|
|
||||||
unitTesting = [ "junit", "mockito-core", "mock-kotlin", "classgraph" ]
|
|
||||||
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.bridges;
|
package com.cobblemon.mod.common.bridges;
|
||||||
|
|
||||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
|
import net.minecraft.structure.processor.StructureProcessor;
|
||||||
|
|
||||||
public interface StructureProcessorListBridge {
|
public interface StructureProcessorListBridge {
|
||||||
void append(StructureProcessor processor);
|
void append(StructureProcessor processor);
|
||||||
|
|||||||
+13
-6
@@ -9,8 +9,9 @@
|
|||||||
package com.cobblemon.mod.common.client.render.models.blockbench.pose;
|
package com.cobblemon.mod.common.client.render.models.blockbench.pose;
|
||||||
|
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext;
|
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,17 +42,23 @@ public interface Bone {
|
|||||||
* @param buffer The vertex consumer deployed by the renderer
|
* @param buffer The vertex consumer deployed by the renderer
|
||||||
* @param packedLight The light level to be applied to the bone
|
* @param packedLight The light level to be applied to the bone
|
||||||
* @param packedOverlay The overlay value to be applied to the bone
|
* @param packedOverlay The overlay value to be applied to the bone
|
||||||
* @param color RGBA packed integer color value
|
* @param r A value representing the amount of red coloring that should be applied on the RGB scale
|
||||||
|
* @param g A value representing the amount of green coloring that should be applied on the RGB scale
|
||||||
|
* @param b A value representing the amount of blue coloring that should be applied on the RGB scale
|
||||||
|
* @param a The alpha value to apply to the model based on the RGB scale
|
||||||
*
|
*
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
void render(
|
void render(
|
||||||
RenderContext context,
|
RenderContext context,
|
||||||
PoseStack stack,
|
MatrixStack stack,
|
||||||
VertexConsumer buffer,
|
VertexConsumer buffer,
|
||||||
int packedLight,
|
int packedLight,
|
||||||
int packedOverlay,
|
int packedOverlay,
|
||||||
int color
|
float r,
|
||||||
|
float g,
|
||||||
|
float b,
|
||||||
|
float a
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,5 +66,5 @@ public interface Bone {
|
|||||||
*
|
*
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
void transform(PoseStack matrixStack);
|
void transform(MatrixStack matrixStack);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 Cobblemon Contributors
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.cobblemon.mod.common.compat;
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.CobblemonEntities;
|
||||||
|
import com.cobblemon.mod.common.client.render.layer.PokemonOnShoulderRenderer;
|
||||||
|
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||||
|
import com.cobblemon.mod.common.pokemon.FormData;
|
||||||
|
import com.cobblemon.mod.common.pokemon.lighthing.LightingData;
|
||||||
|
import dev.lambdaurora.lambdynlights.api.DynamicLightHandler;
|
||||||
|
import dev.lambdaurora.lambdynlights.api.DynamicLightHandlers;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.util.Pair;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
// Java class due to relying on entrypoint on Fabric side
|
||||||
|
public class LambDynamicLightsCompat {
|
||||||
|
|
||||||
|
// This is all called on client side
|
||||||
|
// These things are checked every tick so try to keep it as free as possible
|
||||||
|
// That being said it's unlikely school Toshiba person is running dynamic lighting and shaders to enjoy this
|
||||||
|
// Make sure not to call anything Fabric specific :)
|
||||||
|
public static void hookCompat() {
|
||||||
|
// Pokémon entities
|
||||||
|
DynamicLightHandlers.registerDynamicLightHandler(
|
||||||
|
CobblemonEntities.POKEMON,
|
||||||
|
DynamicLightHandler.makeHandler(
|
||||||
|
pokemon -> resolvedPokemonLightLevel(pokemon, false),
|
||||||
|
pokemon -> true
|
||||||
|
)
|
||||||
|
);
|
||||||
|
DynamicLightHandlers.registerDynamicLightHandler(
|
||||||
|
CobblemonEntities.POKEMON,
|
||||||
|
DynamicLightHandler.makeHandler(
|
||||||
|
pokemon -> resolvedPokemonLightLevel(pokemon, true),
|
||||||
|
pokemon -> false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Shouldered Pokémon
|
||||||
|
DynamicLightHandlers.registerDynamicLightHandler(
|
||||||
|
EntityType.PLAYER,
|
||||||
|
DynamicLightHandler.makeHandler(
|
||||||
|
player -> resolvedShoulderLightLevel(player, false),
|
||||||
|
player -> true
|
||||||
|
)
|
||||||
|
);
|
||||||
|
DynamicLightHandlers.registerDynamicLightHandler(
|
||||||
|
EntityType.PLAYER,
|
||||||
|
DynamicLightHandler.makeHandler(
|
||||||
|
player -> resolvedShoulderLightLevel(player, true),
|
||||||
|
player -> false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int resolvedPokemonLightLevel(PokemonEntity pokemon, boolean underwater) {
|
||||||
|
return extractFormLightLevel(pokemon.getForm(), underwater).orElse(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int resolvedShoulderLightLevel(PlayerEntity player, boolean underwater) {
|
||||||
|
final Pair<PokemonOnShoulderRenderer.ShoulderData, PokemonOnShoulderRenderer.ShoulderData> shoulderDataPair = PokemonOnShoulderRenderer.shoulderDataOf(player);
|
||||||
|
final Optional<Integer> leftLightLevel = extractShoulderLightLevel(shoulderDataPair.getLeft(), underwater);
|
||||||
|
final Optional<Integer> rightLightLevel = extractShoulderLightLevel(shoulderDataPair.getRight(), underwater);
|
||||||
|
return Math.max(leftLightLevel.orElse(0), rightLightLevel.orElse(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Optional<Integer> extractFormLightLevel(@NotNull FormData form, boolean underwater) {
|
||||||
|
if (form.getLightingData() == null || !liquidGlowModeSupport(form.getLightingData().getLiquidGlowMode(), underwater)) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
return Optional.of(form.getLightingData().getLightLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Optional<Integer> extractShoulderLightLevel(@Nullable PokemonOnShoulderRenderer.ShoulderData shoulderData, boolean underwater) {
|
||||||
|
if (shoulderData == null) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
return extractFormLightLevel(shoulderData.getForm(), underwater);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean liquidGlowModeSupport(@NotNull LightingData.LiquidGlowMode liquidGlowMode, boolean underwater) {
|
||||||
|
return underwater ? liquidGlowMode.getGlowsUnderwater() : liquidGlowMode.getGlowsInLand();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.duck;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
|
||||||
|
|
||||||
public interface SoundEngineDuck {
|
|
||||||
|
|
||||||
void pauseSounds(@Nullable ResourceLocation id, @Nullable SoundSource category);
|
|
||||||
|
|
||||||
void resumeSounds(@Nullable ResourceLocation id, @Nullable SoundSource category);
|
|
||||||
}
|
|
||||||
@@ -8,13 +8,13 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.duck;
|
package com.cobblemon.mod.common.duck;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.util.Identifier;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public interface SoundManagerDuck {
|
public interface SoundManagerDuck {
|
||||||
|
|
||||||
void pauseSounds(@Nullable ResourceLocation id, @Nullable SoundSource category);
|
void pauseSounds(@Nullable Identifier id, @Nullable SoundCategory category);
|
||||||
|
|
||||||
void resumeSounds(@Nullable ResourceLocation id, @Nullable SoundSource category);
|
void resumeSounds(@Nullable Identifier id, @Nullable SoundCategory category);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 Cobblemon Contributors
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.cobblemon.mod.common.duck;
|
||||||
|
|
||||||
|
import net.minecraft.client.sound.SoundInstance;
|
||||||
|
import net.minecraft.sound.SoundCategory;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public interface SoundSystemDuck {
|
||||||
|
|
||||||
|
void pauseSounds(@Nullable Identifier id, @Nullable SoundCategory category);
|
||||||
|
|
||||||
|
void resumeSounds(@Nullable Identifier id, @Nullable SoundCategory category);
|
||||||
|
|
||||||
|
Collection<SoundInstance> getSounds(@Nullable SoundCategory category);
|
||||||
|
}
|
||||||
+9
-8
@@ -10,21 +10,22 @@ package com.cobblemon.mod.common.mixin;
|
|||||||
|
|
||||||
import com.cobblemon.mod.common.client.render.item.CobblemonBuiltinItemRenderer;
|
import com.cobblemon.mod.common.client.render.item.CobblemonBuiltinItemRenderer;
|
||||||
import com.cobblemon.mod.common.client.render.item.CobblemonBuiltinItemRendererRegistry;
|
import com.cobblemon.mod.common.client.render.item.CobblemonBuiltinItemRendererRegistry;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import net.minecraft.client.render.VertexConsumerProvider;
|
||||||
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
|
import net.minecraft.client.render.item.BuiltinModelItemRenderer;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||||
import net.minecraft.world.item.ItemDisplayContext;
|
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(BlockEntityWithoutLevelRenderer.class)
|
@Mixin(BuiltinModelItemRenderer.class)
|
||||||
public class BuiltinModelItemRendererMixin {
|
public class BuiltinModelItemRendererMixin {
|
||||||
|
|
||||||
@Inject(method = "renderByItem", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "render", at = @At("HEAD"), cancellable = true)
|
||||||
private void cobblemon$useDynamicItemRenderer(ItemStack stack, ItemDisplayContext mode, PoseStack matrices, MultiBufferSource vertexConsumers, int light, int overlay, CallbackInfo ci) {
|
private void cobblemon$useDynamicItemRenderer(ItemStack stack, ModelTransformationMode mode, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, CallbackInfo ci) {
|
||||||
CobblemonBuiltinItemRenderer renderer = CobblemonBuiltinItemRendererRegistry.INSTANCE.rendererOf(stack.getItem());
|
CobblemonBuiltinItemRenderer renderer = CobblemonBuiltinItemRendererRegistry.INSTANCE.rendererOf(stack.getItem());
|
||||||
if (renderer != null) {
|
if (renderer != null) {
|
||||||
renderer.render(stack, mode, matrices, vertexConsumers, light, overlay);
|
renderer.render(stack, mode, matrices, vertexConsumers, light, overlay);
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
|
||||||
|
|
||||||
import static com.cobblemon.mod.common.datafixer.CobblemonSchemas.VERSION_KEY;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.datafixer.CobblemonSchemas;
|
|
||||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
|
||||||
import com.mojang.serialization.MapCodec;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.IntTag;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.util.datafix.DataFixTypes;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
|
||||||
import net.minecraft.world.level.chunk.storage.ChunkStorage;
|
|
||||||
import net.minecraft.world.level.storage.DimensionDataStorage;
|
|
||||||
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.ModifyVariable;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
|
|
||||||
@Mixin(ChunkStorage.class)
|
|
||||||
public class ChunkStorageMixin {
|
|
||||||
//Modifies the NBT returned by the vanilla upgradeChunkTag to also incorporate cobblemon fixup stuff
|
|
||||||
@ModifyExpressionValue(
|
|
||||||
method = "upgradeChunkTag(Lnet/minecraft/resources/ResourceKey;Ljava/util/function/Supplier;Lnet/minecraft/nbt/CompoundTag;Ljava/util/Optional;)Lnet/minecraft/nbt/CompoundTag;",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "Lnet/minecraft/util/datafix/DataFixTypes;updateToCurrentVersion(Lcom/mojang/datafixers/DataFixer;Lnet/minecraft/nbt/CompoundTag;I)Lnet/minecraft/nbt/CompoundTag;"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
public CompoundTag cobblemon$doChunkFix(
|
|
||||||
CompoundTag vanillaFixed
|
|
||||||
) {
|
|
||||||
int curVersion = vanillaFixed.contains(VERSION_KEY) ? vanillaFixed.getInt(VERSION_KEY) : 0;
|
|
||||||
return DataFixTypes.CHUNK.update(CobblemonSchemas.getDATA_FIXER(), vanillaFixed, curVersion, CobblemonSchemas.DATA_VERSION);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,8 +9,8 @@
|
|||||||
package com.cobblemon.mod.common.mixin;
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
import com.cobblemon.mod.common.CobblemonBuildDetails;
|
import com.cobblemon.mod.common.CobblemonBuildDetails;
|
||||||
import net.minecraft.CrashReport;
|
import net.minecraft.util.crash.CrashReport;
|
||||||
import net.minecraft.CrashReportCategory;
|
import net.minecraft.util.crash.CrashReportSection;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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;
|
||||||
@@ -19,15 +19,16 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
@Mixin(CrashReport.class)
|
@Mixin(CrashReport.class)
|
||||||
public final class CrashReportMixin {
|
public final class CrashReportMixin {
|
||||||
|
|
||||||
@Inject(method = "getDetails(Ljava/lang/StringBuilder;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/SystemReport;appendToCrashReportString(Ljava/lang/StringBuilder;)V"))
|
@Inject(method = "addStackTrace", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/SystemDetails;writeTo(Ljava/lang/StringBuilder;)V"))
|
||||||
public void cobblemon$printCobblemonDetails(StringBuilder builder, CallbackInfo callback) {
|
public void cobblemon$printCobblemonDetails(StringBuilder builder, CallbackInfo callback) {
|
||||||
CrashReportCategory cobblemon = new CrashReportCategory("Cobblemon");
|
CrashReportSection cobblemon = new CrashReportSection("Cobblemon");
|
||||||
cobblemon.setDetail("Version", CobblemonBuildDetails.VERSION);
|
cobblemon.add("Version", CobblemonBuildDetails.VERSION);
|
||||||
cobblemon.setDetail("Is Snapshot", CobblemonBuildDetails.SNAPSHOT);
|
cobblemon.add("Is Snapshot", CobblemonBuildDetails.SNAPSHOT);
|
||||||
cobblemon.setDetail("Git Commit", CobblemonBuildDetails.INSTANCE.smallCommitHash() + " (" + "https://gitlab.com/cable-mc/cobblemon/-/commit/" + CobblemonBuildDetails.GIT_COMMIT + ")");
|
cobblemon.add("Git Commit", CobblemonBuildDetails.INSTANCE.smallCommitHash() + " (" + "https://gitlab.com/cable-mc/cobblemon/-/commit/" + CobblemonBuildDetails.GIT_COMMIT + ")");
|
||||||
cobblemon.setDetail("Branch", CobblemonBuildDetails.BRANCH);
|
cobblemon.add("Branch", CobblemonBuildDetails.BRANCH);
|
||||||
|
cobblemon.add("Timestamp", CobblemonBuildDetails.TIMESTAMP);
|
||||||
|
|
||||||
cobblemon.getDetails(builder);
|
cobblemon.addStackTrace(builder);
|
||||||
builder.append("\n\n");
|
builder.append("\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,9 @@
|
|||||||
package com.cobblemon.mod.common.mixin;
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
import com.cobblemon.mod.common.sherds.CobblemonSherds;
|
import com.cobblemon.mod.common.sherds.CobblemonSherds;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.block.DecoratedPotPatterns;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.world.level.block.entity.DecoratedPotPattern;
|
import net.minecraft.registry.RegistryKey;
|
||||||
import net.minecraft.world.level.block.entity.DecoratedPotPatterns;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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;
|
||||||
@@ -20,14 +19,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||||||
|
|
||||||
@Mixin(DecoratedPotPatterns.class)
|
@Mixin(DecoratedPotPatterns.class)
|
||||||
public abstract class DecoratedPotPatternsMixin {
|
public abstract class DecoratedPotPatternsMixin {
|
||||||
@Inject(method = "getPatternFromItem", at=@At("HEAD"), cancellable = true)
|
@Inject(method = "fromSherd", at=@At("HEAD"), cancellable = true)
|
||||||
private static void cobblemon$getCobblemonSherdTexture(
|
private static void cobblemon$getCobblemonSherdTexture(Item sherd,
|
||||||
Item sherd,
|
CallbackInfoReturnable<RegistryKey<String>> cir) {
|
||||||
CallbackInfoReturnable<ResourceKey<DecoratedPotPattern>> cir
|
|
||||||
) {
|
|
||||||
if (CobblemonSherds.INSTANCE.getSherdToPattern().containsKey(sherd)) {
|
if (CobblemonSherds.INSTANCE.getSherdToPattern().containsKey(sherd)) {
|
||||||
cir.setReturnValue(CobblemonSherds.INSTANCE.getSherdToPattern().get(sherd));
|
cir.setReturnValue(CobblemonSherds.INSTANCE.getSherdToPattern().get(sherd));
|
||||||
cir.cancel();
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-58
@@ -9,20 +9,10 @@
|
|||||||
package com.cobblemon.mod.common.mixin;
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
import com.cobblemon.mod.common.client.CobblemonClient;
|
import com.cobblemon.mod.common.client.CobblemonClient;
|
||||||
import com.cobblemon.mod.common.client.render.MatrixWrapper;
|
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableModel;
|
import net.minecraft.client.render.entity.EntityRenderer;
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import com.cobblemon.mod.common.entity.PosableEntity;
|
import net.minecraft.resource.ResourceManager;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
|
||||||
import net.minecraft.client.renderer.LevelRenderer;
|
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
|
||||||
import net.minecraft.client.renderer.RenderType;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.phys.AABB;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import org.joml.Vector3f;
|
|
||||||
import org.spongepowered.asm.mixin.Debug;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@@ -30,57 +20,17 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
|
||||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
|
||||||
import net.minecraft.client.resources.PlayerSkin;
|
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
|
|
||||||
@Mixin(EntityRenderDispatcher.class)
|
@Mixin(EntityRenderDispatcher.class)
|
||||||
public class EntityRenderDispatcherMixin {
|
public class EntityRenderDispatcherMixin {
|
||||||
|
|
||||||
@Shadow private Map<PlayerSkin.Model, EntityRenderer<? extends Player>> playerRenderers;
|
@Shadow private Map<String, EntityRenderer<? extends PlayerEntity>> modelRenderers;
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "onResourceManagerReload",
|
method = "reload",
|
||||||
at = @At(value = "TAIL")
|
at = @At(value = "TAIL")
|
||||||
)
|
)
|
||||||
public void resourceManagerReloadHook(ResourceManager resourceManager, CallbackInfo ci) {
|
public void resourceManagerReloadHook(ResourceManager resourceManager, CallbackInfo ci) {
|
||||||
CobblemonClient.INSTANCE.onAddLayer(this.playerRenderers);
|
CobblemonClient.INSTANCE.onAddLayer(this.modelRenderers);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Inject(
|
|
||||||
method = "renderHitbox(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lnet/minecraft/world/entity/Entity;FFFF)V",
|
|
||||||
at = @At(value = "TAIL")
|
|
||||||
)
|
|
||||||
private static void renderLocators(
|
|
||||||
PoseStack poseStack,
|
|
||||||
VertexConsumer buffer,
|
|
||||||
Entity entity,
|
|
||||||
float red,
|
|
||||||
float green,
|
|
||||||
float blue,
|
|
||||||
float alpha,
|
|
||||||
CallbackInfo ci
|
|
||||||
) {
|
|
||||||
if (entity instanceof PosableEntity posableEntity) {
|
|
||||||
if (posableEntity.getDelegate() instanceof PosableState state) {
|
|
||||||
state.getLocatorStates().forEach((locator, matrix) -> {
|
|
||||||
poseStack.pushPose();
|
|
||||||
Vec3 pos = matrix.getOrigin().subtract(entity.position());
|
|
||||||
LevelRenderer.renderLineBox(
|
|
||||||
poseStack,
|
|
||||||
buffer,
|
|
||||||
AABB.ofSize(pos, 0.25, 0.25, 0.25),
|
|
||||||
0F,
|
|
||||||
1F,
|
|
||||||
0F,
|
|
||||||
1F
|
|
||||||
);
|
|
||||||
poseStack.popPose();
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
|
||||||
|
|
||||||
import static com.cobblemon.mod.common.datafixer.CobblemonSchemas.VERSION_KEY;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.datafixer.CobblemonSchemas;
|
|
||||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.IntTag;
|
|
||||||
import net.minecraft.util.datafix.DataFixTypes;
|
|
||||||
import net.minecraft.world.level.chunk.storage.EntityStorage;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
|
|
||||||
@Mixin(EntityStorage.class)
|
|
||||||
public class EntityStorageMixin {
|
|
||||||
//Modifies the NBT returned by the vanilla upgradeChunkTag to also incorporate cobblemon fixup stuff
|
|
||||||
@ModifyExpressionValue(
|
|
||||||
method = "method_31731(Lnet/minecraft/world/level/ChunkPos;Ljava/util/Optional;)Lnet/minecraft/world/level/entity/ChunkEntities;",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "Lnet/minecraft/world/level/chunk/storage/SimpleRegionStorage;upgradeChunkTag(Lnet/minecraft/nbt/CompoundTag;I)Lnet/minecraft/nbt/CompoundTag;"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
public CompoundTag cobblemon$doEntityFix(
|
|
||||||
CompoundTag vanillaFixed
|
|
||||||
) {
|
|
||||||
int curVersion = vanillaFixed.contains(VERSION_KEY) ? vanillaFixed.getInt(VERSION_KEY) : 0;
|
|
||||||
CompoundTag newTag = DataFixTypes.ENTITY_CHUNK.update(CobblemonSchemas.getDATA_FIXER(), vanillaFixed, curVersion, CobblemonSchemas.DATA_VERSION);
|
|
||||||
newTag.put(VERSION_KEY, IntTag.valueOf(CobblemonSchemas.DATA_VERSION));
|
|
||||||
return newTag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,24 +8,24 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import net.minecraft.entity.passive.VillagerEntity;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import net.minecraft.item.ItemStack;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import net.minecraft.village.VillagerProfession;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import com.cobblemon.mod.common.villager.VillagerGatherableItems;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
import com.cobblemon.mod.common.villager.VillagerGatherableItems;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import net.minecraft.world.entity.npc.Villager;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
|
|
||||||
@Mixin(Villager.class)
|
@Mixin(VillagerEntity.class)
|
||||||
public abstract class EntityVillagerMixin {
|
public abstract class EntityVillagerMixin {
|
||||||
|
|
||||||
@Inject(method = "wantsToPickUp", at = @At(value = "RETURN"), cancellable = true)
|
@Inject(method = "canGather", at = @At(value = "RETURN"), cancellable = true)
|
||||||
private void cobblemon$canGather(ItemStack stack, CallbackInfoReturnable<Boolean> ci) {
|
private void cobblemon$canGather(ItemStack stack, CallbackInfoReturnable<Boolean> ci) {
|
||||||
final Villager villager = (Villager) (Object) this;
|
final VillagerEntity villager = (VillagerEntity) (Object) this;
|
||||||
if(ci.getReturnValue() == false && Objects.equals(villager.getVillagerData().getProfession(), VillagerProfession.FARMER) && villager.getInventory().canAddItem(stack)) {
|
if(ci.getReturnValue() == false && Objects.equals(villager.getVillagerData().getProfession(), VillagerProfession.FARMER) && villager.getInventory().canInsert(stack)) {
|
||||||
if(VillagerGatherableItems.INSTANCE.getVillagerGatherableItems().contains(stack.getItem()))
|
if(VillagerGatherableItems.INSTANCE.getVillagerGatherableItems().contains(stack.getItem()))
|
||||||
ci.setReturnValue(true);
|
ci.setReturnValue(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,10 @@
|
|||||||
package com.cobblemon.mod.common.mixin;
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
import com.cobblemon.mod.common.block.PreEmptsExplosion;
|
import com.cobblemon.mod.common.block.PreEmptsExplosion;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.world.level.Explosion;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.explosion.Explosion;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
@@ -21,14 +21,14 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
|||||||
public class ExplosionMixin {
|
public class ExplosionMixin {
|
||||||
|
|
||||||
@Redirect(
|
@Redirect(
|
||||||
method = "finalizeExplosion",
|
method = "affectWorld",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/world/level/Level;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;",
|
target = "Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;",
|
||||||
ordinal = 0
|
ordinal = 0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
public BlockState cobblemon$whenExploded(Level world, BlockPos pos) {
|
public BlockState cobblemon$whenExploded(World world, BlockPos pos) {
|
||||||
BlockState blockState = world.getBlockState(pos);
|
BlockState blockState = world.getBlockState(pos);
|
||||||
if(blockState.getBlock() instanceof PreEmptsExplosion preExplosionBlock) {
|
if(blockState.getBlock() instanceof PreEmptsExplosion preExplosionBlock) {
|
||||||
preExplosionBlock.whenExploded(world, blockState, pos);
|
preExplosionBlock.whenExploded(world, blockState, pos);
|
||||||
|
|||||||
@@ -9,9 +9,8 @@
|
|||||||
package com.cobblemon.mod.common.mixin;
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
import com.cobblemon.mod.common.api.scheduling.ClientTaskTracker;
|
import com.cobblemon.mod.common.api.scheduling.ClientTaskTracker;
|
||||||
import net.minecraft.client.DeltaTracker;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.render.GameRenderer;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@@ -27,8 +26,8 @@ public class GameRendererMixin {
|
|||||||
method = "render",
|
method = "render",
|
||||||
at = @At(value = "TAIL")
|
at = @At(value = "TAIL")
|
||||||
)
|
)
|
||||||
public void render(DeltaTracker counter, boolean tick, CallbackInfo ci) {
|
public void render(float tickDelta, long startTime, boolean tick, CallbackInfo ci) {
|
||||||
Minecraft client = Minecraft.getInstance();
|
MinecraftClient client = MinecraftClient.getInstance();
|
||||||
long newTime = System.currentTimeMillis();
|
long newTime = System.currentTimeMillis();
|
||||||
// Don't play scheduled animations when the game is paused
|
// Don't play scheduled animations when the game is paused
|
||||||
if (client.isPaused()) {
|
if (client.isPaused()) {
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.item.PokedexItem;
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.player.AbstractClientPlayer;
|
|
||||||
import net.minecraft.client.renderer.ItemInHandRenderer;
|
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
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(ItemInHandRenderer.class)
|
|
||||||
public class ItemInHandRendererMixin {
|
|
||||||
@Inject(method = "renderArmWithItem", at = @At(value = "HEAD"), cancellable = true)
|
|
||||||
private void cobblemon$renderArmWithItem(AbstractClientPlayer abstractClientPlayer, float f, float g, InteractionHand interactionHand, float h, ItemStack itemStack, float i, PoseStack poseStack, MultiBufferSource multiBufferSource, int j, CallbackInfo ci) {
|
|
||||||
if (abstractClientPlayer.isUsingItem() && abstractClientPlayer.getUseItem().getItem() instanceof PokedexItem) {
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.entity.fishing.PokeRodFishingBobberEntity;
|
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
|
||||||
import net.minecraft.client.renderer.item.ItemProperties;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
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(ItemProperties.class)
|
|
||||||
public class ItemPropertiesMixin {
|
|
||||||
|
|
||||||
// Mixins into the fishing rod's register() lambda expression
|
|
||||||
// Without this, the fishing rod item model appears cast when using a PokeRod in the other hand
|
|
||||||
@Inject(method = "method_27883", at = @At(value = "RETURN", ordinal = 1), cancellable = true)
|
|
||||||
private static void cobblemon$preventRodMixup(ItemStack itemStack, ClientLevel clientLevel, LivingEntity livingEntity, int i, CallbackInfoReturnable<Float> cir) {
|
|
||||||
if (!(livingEntity instanceof Player) || ((Player) livingEntity).fishing instanceof PokeRodFishingBobberEntity) {
|
|
||||||
cir.setReturnValue(0.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.Cobblemon;
|
|
||||||
import com.cobblemon.mod.common.ModAPI;
|
|
||||||
import com.cobblemon.mod.common.item.PokeBallItem;
|
|
||||||
import com.cobblemon.mod.common.item.PokedexItem;
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
|
||||||
import net.minecraft.client.renderer.ItemModelShaper;
|
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
|
||||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
|
||||||
import net.minecraft.client.resources.model.BakedModel;
|
|
||||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.ItemDisplayContext;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.spongepowered.asm.mixin.Final;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
|
|
||||||
/*
|
|
||||||
I think it would be nice to maybe use the existing mixin we have for custom item rendering [BuiltinModelItemRendererMixin]
|
|
||||||
Obviously that would require changes. Potentially each item renderer defines what modes it overrides for?
|
|
||||||
*/
|
|
||||||
@Mixin(ItemRenderer.class)
|
|
||||||
public abstract class ItemRendererMixin {
|
|
||||||
@Unique private final String MODEL_PATH = Cobblemon.implementation.getModAPI() == ModAPI.FABRIC ? "fabric_resource" : "standalone";
|
|
||||||
|
|
||||||
@Shadow @Final private ItemModelShaper itemModelShaper;
|
|
||||||
|
|
||||||
@Shadow public abstract void render(ItemStack stack, ItemDisplayContext renderMode, boolean leftHanded, PoseStack matrices, MultiBufferSource vertexConsumers, int light, int overlay, BakedModel model);
|
|
||||||
|
|
||||||
@Inject(
|
|
||||||
method = "render(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemDisplayContext;ZLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;IILnet/minecraft/client/resources/model/BakedModel;)V",
|
|
||||||
at = @At("HEAD"),
|
|
||||||
cancellable = true
|
|
||||||
)
|
|
||||||
private void cobblemon$overrideItemModel(ItemStack stack, ItemDisplayContext renderMode, boolean leftHanded, PoseStack matrices, MultiBufferSource multiBufferSource, int light, int overlay, BakedModel model, CallbackInfo ci) {
|
|
||||||
boolean shouldBe2d = renderMode == ItemDisplayContext.GUI || renderMode == ItemDisplayContext.FIXED;
|
|
||||||
if (shouldBe2d) {
|
|
||||||
ResourceLocation resourceLocation = null;
|
|
||||||
if (stack.getItem() instanceof PokeBallItem pokeBallItem) resourceLocation = pokeBallItem.getPokeBall().getModel2d();
|
|
||||||
else if (stack.getItem() instanceof PokedexItem pokedexItem) resourceLocation = pokedexItem.getType().getItemSpritePath();
|
|
||||||
|
|
||||||
if (resourceLocation != null) {
|
|
||||||
BakedModel replacementModel = this.itemModelShaper.getModelManager().getModel(new ModelResourceLocation(resourceLocation, "inventory"));
|
|
||||||
if (!cobblemon$isSameModel(model, replacementModel)) {
|
|
||||||
ci.cancel();
|
|
||||||
render(stack, renderMode, leftHanded, matrices, multiBufferSource, light, overlay, replacementModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "getModel", at = @At("HEAD"), cancellable = true)
|
|
||||||
private void cobblemon$getItemModel(ItemStack stack, Level world, LivingEntity entity, int seed, CallbackInfoReturnable<BakedModel> cir) {
|
|
||||||
ResourceLocation resourceLocation = null;
|
|
||||||
if (stack.getItem() instanceof PokeBallItem pokeBallItem) resourceLocation = pokeBallItem.getPokeBall().getModel3d();
|
|
||||||
else if (stack.getItem() instanceof PokedexItem pokedexItem) {
|
|
||||||
boolean isScanModel = entity instanceof Player && entity.getUseItem() == stack && entity.isUsingItem();
|
|
||||||
boolean canOpenScreen = entity != null && ((entity.getOffhandItem() == stack && !(entity.getMainHandItem().getItem() instanceof PokedexItem)) || entity.getMainHandItem() == stack);
|
|
||||||
resourceLocation = pokedexItem.getType().getItemModelPath(isScanModel ? "scanning" : (canOpenScreen ? null : "off"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resourceLocation != null) {
|
|
||||||
BakedModel model = this.itemModelShaper.getModelManager().getModel(new ModelResourceLocation(resourceLocation, MODEL_PATH));
|
|
||||||
ClientLevel clientWorld = world instanceof ClientLevel ? (ClientLevel) world : null;
|
|
||||||
BakedModel overriddenModel = model.getOverrides().resolve(model, stack, clientWorld, entity, seed);
|
|
||||||
cir.setReturnValue(overriddenModel == null ? this.itemModelShaper.getModelManager().getMissingModel() : overriddenModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// this method aims to cover an issue with modernfixes and it's "dynamic resource" causing the usual .equals check to always fail, resulting in a StackOverflow
|
|
||||||
// this falls back to comparing the model contents (e.g. location of the texture, width and height)
|
|
||||||
@Unique
|
|
||||||
private static boolean cobblemon$isSameModel(BakedModel original, BakedModel replacement) {
|
|
||||||
return original.equals(replacement) ||
|
|
||||||
(original.getParticleIcon().contents().name().equals(replacement.getParticleIcon().contents().name()) &&
|
|
||||||
original.getParticleIcon().contents().width() == replacement.getParticleIcon().contents().width() &&
|
|
||||||
original.getParticleIcon().contents().height() == replacement.getParticleIcon().contents().height());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-50
@@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.util.DataKeys;
|
|
||||||
import com.mojang.serialization.Dynamic;
|
|
||||||
import net.minecraft.util.datafix.fixes.ItemStackComponentizationFix;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
|
||||||
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.stream.Stream;
|
|
||||||
|
|
||||||
@Mixin(ItemStackComponentizationFix.class)
|
|
||||||
public class ItemStackComponentizationFixMixin
|
|
||||||
{
|
|
||||||
@Inject(method = "fixItemStack", at = @At("TAIL"))
|
|
||||||
private static void fixItemStack(ItemStackComponentizationFix.ItemStackData itemStackData, Dynamic<?> dynamic, CallbackInfo ci) {
|
|
||||||
cobblemon$attemptPokemonModelDataFix(itemStackData, dynamic);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Unique
|
|
||||||
private static void cobblemon$attemptPokemonModelDataFix(ItemStackComponentizationFix.ItemStackData itemStackData, Dynamic<?> dynamic)
|
|
||||||
{
|
|
||||||
var species = itemStackData.removeTag(DataKeys.POKEMON_ITEM_SPECIES).asString();
|
|
||||||
var aspects = itemStackData.removeTag(DataKeys.POKEMON_ITEM_ASPECTS).asList(dynamic1 -> dynamic1);
|
|
||||||
var redTint = itemStackData.removeTag(DataKeys.POKEMON_ITEM_TINT_RED).asNumber();
|
|
||||||
var greenTint = itemStackData.removeTag(DataKeys.POKEMON_ITEM_TINT_GREEN).asNumber();
|
|
||||||
var blueTint = itemStackData.removeTag(DataKeys.POKEMON_ITEM_TINT_BLUE).asNumber();
|
|
||||||
var alphaTint = itemStackData.removeTag(DataKeys.POKEMON_ITEM_TINT_ALPHA).asNumber();
|
|
||||||
if(species.hasResultOrPartial() && aspects != null) {
|
|
||||||
var pokeComponent = dynamic.emptyMap().set("species", dynamic.createString(species.getOrThrow()));
|
|
||||||
pokeComponent = pokeComponent.set("aspects", dynamic.createList(aspects.stream()));
|
|
||||||
if(redTint.hasResultOrPartial() || blueTint.hasResultOrPartial() || greenTint.hasResultOrPartial() || alphaTint.hasResultOrPartial()) {
|
|
||||||
pokeComponent = pokeComponent.set("tint", dynamic.createList(Stream.of(redTint, greenTint, blueTint, alphaTint)
|
|
||||||
.map(x -> x.mapOrElse(Number::floatValue, error -> 0F))
|
|
||||||
.map(dynamic::createFloat)));
|
|
||||||
}
|
|
||||||
itemStackData.setComponent("cobblemon:pokemon_item", pokeComponent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.block.entity.LecternBlockEntity;
|
|
||||||
import com.cobblemon.mod.common.CobblemonBlocks;
|
|
||||||
import com.cobblemon.mod.common.CobblemonSounds;
|
|
||||||
import com.cobblemon.mod.common.item.PokedexItem;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
|
||||||
import net.minecraft.world.ItemInteractionResult;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
|
||||||
import net.minecraft.world.level.block.LecternBlock;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
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;
|
|
||||||
|
|
||||||
import static net.minecraft.world.level.block.LecternBlock.HAS_BOOK;
|
|
||||||
|
|
||||||
@Mixin(LecternBlock.class)
|
|
||||||
public abstract class LecternBlockMixin {
|
|
||||||
@Inject(method = "useItemOn", at = @At(value = "HEAD"), cancellable = true)
|
|
||||||
private void cobblemon$useItemOn(ItemStack itemStack, BlockState blockState, Level world, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult, CallbackInfoReturnable<ItemInteractionResult> cir) {
|
|
||||||
if (!world.isClientSide && itemStack.getItem() instanceof PokedexItem) {
|
|
||||||
BlockEntity blockEntity = world.getBlockEntity(blockPos);
|
|
||||||
if (!blockState.getValue(HAS_BOOK)
|
|
||||||
&& blockEntity instanceof net.minecraft.world.level.block.entity.LecternBlockEntity
|
|
||||||
&& blockState.getBlock() instanceof LecternBlock
|
|
||||||
) {
|
|
||||||
ItemStack pokedexItemStack = itemStack.copy();
|
|
||||||
Direction facing = blockState.getValue(HorizontalDirectionalBlock.FACING);
|
|
||||||
itemStack.consumeAndReturn(1, player);
|
|
||||||
blockEntity.setRemoved();
|
|
||||||
BlockState newBlockState = CobblemonBlocks.LECTERN.defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, facing);
|
|
||||||
world.setBlockAndUpdate(blockPos, newBlockState);
|
|
||||||
BlockEntity lecternEntity = world.getBlockEntity(blockPos);
|
|
||||||
|
|
||||||
if (lecternEntity instanceof LecternBlockEntity) {
|
|
||||||
((LecternBlockEntity) lecternEntity).setItemStack((pokedexItemStack));
|
|
||||||
world.playSound(null, blockPos, CobblemonSounds.POKEDEX_CLOSE, SoundSource.BLOCKS, 0.5F, 1.25F);
|
|
||||||
cir.setReturnValue(ItemInteractionResult.SUCCESS);
|
|
||||||
} else {
|
|
||||||
cir.setReturnValue(itemStack.isEmpty() && interactionHand == InteractionHand.MAIN_HAND ? ItemInteractionResult.SKIP_DEFAULT_BLOCK_INTERACTION : ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,9 +9,9 @@
|
|||||||
package com.cobblemon.mod.common.mixin;
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
import com.cobblemon.mod.common.api.pokemon.effect.ShoulderEffectRegistry;
|
import com.cobblemon.mod.common.api.pokemon.effect.ShoulderEffectRegistry;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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;
|
||||||
@@ -20,11 +20,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
@Mixin(LivingEntity.class)
|
@Mixin(LivingEntity.class)
|
||||||
public abstract class LivingEntityMixin {
|
public abstract class LivingEntityMixin {
|
||||||
|
|
||||||
@Inject(method = "onEffectRemoved", at = @At(value = "TAIL"))
|
@Inject(method = "onStatusEffectRemoved", at = @At(value = "TAIL"))
|
||||||
private void cobblemon$onEffectRemoved(MobEffectInstance effect, CallbackInfo ci) {
|
private void cobblemon$onStatusEffectRemoved(StatusEffectInstance effect, CallbackInfo ci) {
|
||||||
final LivingEntity entity = (LivingEntity) (Object) this;
|
final LivingEntity entity = (LivingEntity) (Object) this;
|
||||||
if (entity instanceof ServerPlayer) {
|
if (entity instanceof ServerPlayerEntity) {
|
||||||
ShoulderEffectRegistry.INSTANCE.onEffectEnd((ServerPlayer) entity);
|
ShoulderEffectRegistry.INSTANCE.onEffectEnd((ServerPlayerEntity) entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -9,20 +9,20 @@
|
|||||||
package com.cobblemon.mod.common.mixin;
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||||
import net.minecraft.server.ServerInterface;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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;
|
||||||
|
|
||||||
@Mixin(ServerLevel.class)
|
@Mixin(ServerWorld.class)
|
||||||
public abstract class MinecraftDedicatedServerMixin implements ServerInterface {
|
public abstract class MinecraftDedicatedServerMixin implements DedicatedServer {
|
||||||
|
|
||||||
@Inject(method = "shouldDiscardEntity", at = @At(value = "HEAD"), cancellable = true)
|
@Inject(method = "shouldCancelSpawn", at = @At(value = "HEAD"), cancellable = true)
|
||||||
public void cobblemon$allowPokemonSpawns(Entity entity, CallbackInfoReturnable<Boolean> callback) {
|
public void cobblemon$allowPokemonSpawns(Entity entity, CallbackInfoReturnable<Boolean> callback) {
|
||||||
if (entity instanceof PokemonEntity) {
|
if(entity instanceof PokemonEntity) {
|
||||||
callback.setReturnValue(false);
|
callback.setReturnValue(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,41 +9,61 @@
|
|||||||
package com.cobblemon.mod.common.mixin;
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
import com.cobblemon.mod.common.client.CobblemonBakingOverrides;
|
import com.cobblemon.mod.common.client.CobblemonBakingOverrides;
|
||||||
import java.util.List;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import net.minecraft.client.color.block.BlockColors;
|
import net.minecraft.client.color.block.BlockColors;
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
import net.minecraft.client.render.model.ModelLoader;
|
||||||
import net.minecraft.client.resources.model.BlockStateModelLoader;
|
import net.minecraft.client.render.model.UnbakedModel;
|
||||||
import net.minecraft.client.resources.model.ModelBakery;
|
import net.minecraft.client.render.model.json.JsonUnbakedModel;
|
||||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
import net.minecraft.client.util.ModelIdentifier;
|
||||||
import net.minecraft.client.resources.model.UnbakedModel;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.util.profiler.Profiler;
|
||||||
import net.minecraft.util.profiling.ProfilerFiller;
|
import org.slf4j.Logger;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
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.InjectionPoint;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.points.BeforeStringInvoke;
|
||||||
|
|
||||||
@Mixin(ModelBakery.class)
|
@Mixin(ModelLoader.class)
|
||||||
public abstract class ModelLoaderMixin {
|
public abstract class ModelLoaderMixin {
|
||||||
|
|
||||||
@Shadow abstract UnbakedModel getModel(ResourceLocation resourceLocation);
|
@Shadow protected abstract void addModel(ModelIdentifier modelId);
|
||||||
|
|
||||||
@Shadow protected abstract void registerModel(ModelResourceLocation modelId, UnbakedModel unbakedModel);
|
@Final
|
||||||
|
@Shadow
|
||||||
|
private Map<Identifier, UnbakedModel> unbakedModels;
|
||||||
|
|
||||||
|
@Final
|
||||||
|
@Shadow
|
||||||
|
private static Logger LOGGER;
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "<init>",
|
method = "<init>",
|
||||||
at = @At("TAIL")
|
at = @At("TAIL")
|
||||||
)
|
)
|
||||||
public void init(BlockColors blockColors,
|
public void init(BlockColors blockColors,
|
||||||
ProfilerFiller profiler,
|
Profiler profiler,
|
||||||
Map<ResourceLocation, BlockModel> jsonUnbakedModels,
|
Map jsonUnbakedModels,
|
||||||
Map<ResourceLocation, List<BlockStateModelLoader.LoadedJson>> blockStates,
|
Map blockStates,
|
||||||
CallbackInfo ci) {
|
CallbackInfo ci) {
|
||||||
CobblemonBakingOverrides.INSTANCE.getModels().forEach(bakingOverride -> {
|
CobblemonBakingOverrides.INSTANCE.getModels().forEach(bakingOverride -> {
|
||||||
var unbakedModel = this.getModel(bakingOverride.getModelLocation());
|
try {
|
||||||
this.registerModel(bakingOverride.getModelIdentifier(), unbakedModel);
|
this.unbakedModels.put(bakingOverride.getModelIdentifier(), this.loadModelFromJson(bakingOverride.getModelLocation()));
|
||||||
|
this.addModel(bakingOverride.getModelIdentifier());
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOGGER.error("Error loading a Cobblemon BakedModel:", e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
private JsonUnbakedModel loadModelFromJson(Identifier id) throws IOException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,23 +8,25 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.client.render.models.blockbench.PoseableEntityModel;
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Bone;
|
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Bone;
|
||||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext;
|
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import net.minecraft.client.model.ModelPart;
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import net.minecraft.client.model.geom.ModelPart;
|
|
||||||
|
|
||||||
@Mixin(ModelPart.class)
|
@Mixin(ModelPart.class)
|
||||||
public abstract class ModelPartMixin implements Bone {
|
public abstract class ModelPartMixin implements Bone {
|
||||||
@Shadow public abstract void render(PoseStack matrices, VertexConsumer vertices, int light, int overlay, int color);
|
@Shadow public abstract void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha);
|
||||||
|
|
||||||
@Shadow public abstract void translateAndRotate(PoseStack matrixStack);
|
@Shadow public abstract void rotate(MatrixStack matrixStack);
|
||||||
|
|
||||||
@Shadow @Final
|
@Shadow @Final
|
||||||
public Map<String, ModelPart> children;
|
public Map<String, ModelPart> children;
|
||||||
@@ -36,12 +38,12 @@ public abstract class ModelPartMixin implements Bone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(RenderContext context, PoseStack stack, VertexConsumer buffer, int packedLight, int packedOverlay, int color) {
|
public void render(RenderContext context, MatrixStack stack, VertexConsumer buffer, int packedLight, int packedOverlay, float r, float g, float b, float a) {
|
||||||
this.render(stack, buffer, packedLight, packedOverlay, color);
|
this.render(stack, buffer, packedLight, packedOverlay, r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transform(PoseStack matrixStack) {
|
public void transform(MatrixStack matrixStack) {
|
||||||
this.translateAndRotate(matrixStack);
|
this.rotate(matrixStack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.client.CobblemonClient;
|
|
||||||
import com.cobblemon.mod.common.client.keybind.keybinds.PartySendBinding;
|
|
||||||
import com.cobblemon.mod.common.pokedex.scanner.PokedexUsageContext;
|
|
||||||
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
|
|
||||||
import com.llamalad7.mixinextras.sugar.Local;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.MouseHandler;
|
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
|
||||||
import net.minecraft.util.Mth;
|
|
||||||
import net.minecraft.util.SmoothDouble;
|
|
||||||
import org.objectweb.asm.Opcodes;
|
|
||||||
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.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(MouseHandler.class)
|
|
||||||
public class MouseHandlerMixin {
|
|
||||||
@Shadow
|
|
||||||
private double accumulatedScrollY;
|
|
||||||
|
|
||||||
@Shadow @Final private Minecraft minecraft;
|
|
||||||
|
|
||||||
@Shadow @Final private SmoothDouble smoothTurnY;
|
|
||||||
|
|
||||||
@Shadow @Final private SmoothDouble smoothTurnX;
|
|
||||||
|
|
||||||
@Shadow private double accumulatedDX;
|
|
||||||
|
|
||||||
@Shadow private double accumulatedDY;
|
|
||||||
|
|
||||||
@Inject(
|
|
||||||
method = "onScroll",
|
|
||||||
at = @At(
|
|
||||||
value = "FIELD",
|
|
||||||
target="Lnet/minecraft/client/MouseHandler;accumulatedScrollY:D",
|
|
||||||
opcode = Opcodes.PUTFIELD,
|
|
||||||
ordinal = 2,
|
|
||||||
shift = At.Shift.BEFORE
|
|
||||||
),
|
|
||||||
cancellable = true
|
|
||||||
)
|
|
||||||
public void cobblemon$scrollParty(long window, double horizontal, double vertical, CallbackInfo ci) {
|
|
||||||
if (PartySendBinding.INSTANCE.getWasDown()) {
|
|
||||||
int i = (int) accumulatedScrollY;
|
|
||||||
if (i > 0) {
|
|
||||||
accumulatedScrollY -= i;
|
|
||||||
CobblemonClient.INSTANCE.getStorage().shiftSelected(false);
|
|
||||||
ci.cancel();
|
|
||||||
PartySendBinding.INSTANCE.actioned();
|
|
||||||
} else if (i < 0) {
|
|
||||||
accumulatedScrollY -= i;
|
|
||||||
CobblemonClient.INSTANCE.getStorage().shiftSelected(true);
|
|
||||||
ci.cancel();
|
|
||||||
PartySendBinding.INSTANCE.actioned();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(
|
|
||||||
method = "onScroll",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "Lnet/minecraft/world/entity/player/Inventory;swapPaint(D)V"
|
|
||||||
),
|
|
||||||
cancellable = true
|
|
||||||
)
|
|
||||||
public void cobblemon$doPokedexZoom(long window, double horizontal, double vertical, CallbackInfo ci) {
|
|
||||||
PokedexUsageContext usageContext = CobblemonClient.INSTANCE.getPokedexUsageContext();
|
|
||||||
if (usageContext.getScanningGuiOpen()) {
|
|
||||||
usageContext.adjustZoom(vertical);
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@WrapWithCondition(
|
|
||||||
method = "turnPlayer",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "Lnet/minecraft/client/player/LocalPlayer;turn(DD)V"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
public boolean cobblemon$modifyRotation(LocalPlayer player, double cursorDeltaX, double cursorDeltaY, @Local(argsOnly = true) double d) {
|
|
||||||
// I know this technically doesn't need to be a WrapWithCondition, but it'll make things easier later for riding.
|
|
||||||
PokedexUsageContext usageContext = CobblemonClient.INSTANCE.getPokedexUsageContext();
|
|
||||||
if (usageContext.getScanningGuiOpen()) {
|
|
||||||
this.smoothTurnY.reset();
|
|
||||||
this.smoothTurnX.reset();
|
|
||||||
var defaultSensitivity = this.minecraft.options.sensitivity().get() * 0.6000000238418579 + 0.20000000298023224;
|
|
||||||
var spyglassSensitivity = Math.pow(defaultSensitivity, 3);
|
|
||||||
var lookSensitivity = spyglassSensitivity * 8.0;
|
|
||||||
var sensitivity = Mth.lerp(usageContext.getFovMultiplier(), spyglassSensitivity, lookSensitivity);
|
|
||||||
player.turn(this.accumulatedDX * sensitivity, (this.accumulatedDY * sensitivity));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.client.sound.BattleMusicController;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
|
||||||
import net.minecraft.client.sounds.MusicManager;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
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.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(MusicManager.class)
|
|
||||||
public class MusicManagerMixin {
|
|
||||||
|
|
||||||
@Shadow @Final
|
|
||||||
private Minecraft minecraft;
|
|
||||||
|
|
||||||
@Shadow @Nullable
|
|
||||||
private SoundInstance currentMusic;
|
|
||||||
|
|
||||||
/** Freezes the tracker while a BattleMusicInstance is in progress. Current SoundInstance being tracked will be paused by BattleMusicHandler. */
|
|
||||||
@Inject(method = "tick()V", at = @At("HEAD"), cancellable = true)
|
|
||||||
public void tick(CallbackInfo cb) {
|
|
||||||
if (this.minecraft.getSoundManager().isActive(BattleMusicController.INSTANCE.getMusic())) cb.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 Cobblemon Contributors
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.client.sound.battle.BattleMusicController;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.sound.MusicTracker;
|
||||||
|
import net.minecraft.client.sound.SoundInstance;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
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.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(MusicTracker.class)
|
||||||
|
public class MusicTrackerMixin {
|
||||||
|
|
||||||
|
@Shadow @Final
|
||||||
|
private MinecraftClient client;
|
||||||
|
|
||||||
|
@Shadow @Nullable
|
||||||
|
private SoundInstance current;
|
||||||
|
|
||||||
|
/** Freezes the tracker while a BattleMusicInstance is in progress. Current SoundInstance being tracked will be paused by BattleMusicHandler. */
|
||||||
|
@Inject(method = "tick()V", at = @At("HEAD"), cancellable = true)
|
||||||
|
public void tick(CallbackInfo cb) {
|
||||||
|
if (this.client.getSoundManager().isPlaying(BattleMusicController.INSTANCE.getMusic())) cb.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
|
||||||
|
|
||||||
import static com.cobblemon.mod.common.datafixer.CobblemonSchemas.VERSION_KEY;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.datafixer.CobblemonSchemas;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.NbtUtils;
|
|
||||||
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(NbtUtils.class)
|
|
||||||
public class NbtUtilsMixin {
|
|
||||||
@Inject(
|
|
||||||
method = "addCurrentDataVersion(Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/nbt/CompoundTag;",
|
|
||||||
at = @At("TAIL")
|
|
||||||
)
|
|
||||||
private static void addCobblemonDataVersion(
|
|
||||||
CompoundTag tag,
|
|
||||||
CallbackInfoReturnable<CompoundTag> cir
|
|
||||||
) {
|
|
||||||
tag.putInt(VERSION_KEY, CobblemonSchemas.DATA_VERSION);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,6 +10,8 @@ package com.cobblemon.mod.common.mixin;
|
|||||||
|
|
||||||
import com.cobblemon.mod.common.api.snowstorm.ParticleMaterials;
|
import com.cobblemon.mod.common.api.snowstorm.ParticleMaterials;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import net.minecraft.client.particle.ParticleManager;
|
||||||
|
import net.minecraft.client.particle.ParticleTextureSheet;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Mutable;
|
import org.spongepowered.asm.mixin.Mutable;
|
||||||
@@ -19,19 +21,17 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.minecraft.client.particle.ParticleEngine;
|
|
||||||
import net.minecraft.client.particle.ParticleRenderType;
|
|
||||||
|
|
||||||
@Mixin(ParticleEngine.class)
|
@Mixin(ParticleManager.class)
|
||||||
final class ParticleManagerMixin {
|
final class ParticleManagerMixin {
|
||||||
@Mutable
|
@Mutable
|
||||||
@Final
|
@Final
|
||||||
@Shadow
|
@Shadow
|
||||||
private static List<ParticleRenderType> RENDER_ORDER;
|
private static List<ParticleTextureSheet> PARTICLE_TEXTURE_SHEETS;
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "<clinit>")
|
@Inject(at = @At("RETURN"), method = "<clinit>")
|
||||||
private static void lodestone$addTypes(CallbackInfo ci) {
|
private static void lodestone$addTypes(CallbackInfo ci) {
|
||||||
RENDER_ORDER = ImmutableList.<ParticleRenderType>builder().addAll(RENDER_ORDER)
|
PARTICLE_TEXTURE_SHEETS = ImmutableList.<ParticleTextureSheet>builder().addAll(PARTICLE_TEXTURE_SHEETS)
|
||||||
.add(ParticleMaterials.INSTANCE.getADD(), ParticleMaterials.INSTANCE.getALPHA(), ParticleMaterials.INSTANCE.getBLEND(), ParticleMaterials.INSTANCE.getOPAQUE()).build();
|
.add(ParticleMaterials.INSTANCE.getADD(), ParticleMaterials.INSTANCE.getALPHA(), ParticleMaterials.INSTANCE.getBLEND(), ParticleMaterials.INSTANCE.getOPAQUE()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 Cobblemon Contributors
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.client.CobblemonClient;
|
||||||
|
import com.cobblemon.mod.common.client.keybind.keybinds.PartySendBinding;
|
||||||
|
import net.minecraft.client.Mouse;
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
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.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(Mouse.class)
|
||||||
|
public class PartyScrollMixin {
|
||||||
|
@Shadow
|
||||||
|
private double eventDeltaWheel;
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "onMouseScroll",
|
||||||
|
at = @At(
|
||||||
|
value = "FIELD",
|
||||||
|
target="Lnet/minecraft/client/Mouse;eventDeltaWheel:D",
|
||||||
|
opcode = Opcodes.PUTFIELD,
|
||||||
|
ordinal = 2,
|
||||||
|
shift = At.Shift.BEFORE
|
||||||
|
),
|
||||||
|
cancellable = true
|
||||||
|
)
|
||||||
|
public void onMouseScroll(long window, double horizontal, double vertical, CallbackInfo ci) {
|
||||||
|
if (PartySendBinding.INSTANCE.getWasDown()) {
|
||||||
|
int i = (int)eventDeltaWheel;
|
||||||
|
if (i > 0) {
|
||||||
|
while (i-- > 0) CobblemonClient.INSTANCE.getStorage().shiftSelected(false);
|
||||||
|
ci.cancel();
|
||||||
|
eventDeltaWheel = 0;
|
||||||
|
PartySendBinding.INSTANCE.actioned();
|
||||||
|
} else if (i < 0) {
|
||||||
|
while (i++ < 0) CobblemonClient.INSTANCE.getStorage().shiftSelected(true);
|
||||||
|
ci.cancel();
|
||||||
|
eventDeltaWheel = 0;
|
||||||
|
PartySendBinding.INSTANCE.actioned();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,22 +9,22 @@
|
|||||||
package com.cobblemon.mod.common.mixin;
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
import com.cobblemon.mod.common.CobblemonItems;
|
import com.cobblemon.mod.common.CobblemonItems;
|
||||||
import net.minecraft.world.entity.monster.piglin.PiglinAi;
|
import net.minecraft.entity.mob.PiglinBrain;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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;
|
||||||
|
|
||||||
|
|
||||||
@Mixin(PiglinAi.class)
|
@Mixin(PiglinBrain.class)
|
||||||
public class PiglinBarterMixin {
|
public class PiglinBarterMixin {
|
||||||
|
|
||||||
@Inject(method = "isBarterCurrency", at = @At(value = "RETURN"), cancellable = true)
|
@Inject(method = "acceptsForBarter", at = @At(value = "RETURN"), cancellable = true)
|
||||||
private static void cobblemon$acceptsForBarter(ItemStack stack, CallbackInfoReturnable<Boolean> ci) {
|
private static void cobblemon$acceptsForBarter(ItemStack stack, CallbackInfoReturnable<Boolean> ci) {
|
||||||
if(!ci.getReturnValue()) {
|
if(!ci.getReturnValue()) {
|
||||||
//TODO: Make a tag?
|
//TODO: Make a tag?
|
||||||
if(stack.is(CobblemonItems.RELIC_COIN_POUCH))
|
if(stack.isOf(CobblemonItems.RELIC_COIN_POUCH))
|
||||||
ci.setReturnValue(true);
|
ci.setReturnValue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,22 +9,22 @@
|
|||||||
package com.cobblemon.mod.common.mixin;
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
import com.cobblemon.mod.common.CobblemonItems;
|
import com.cobblemon.mod.common.CobblemonItems;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.monster.piglin.Piglin;
|
import net.minecraft.entity.mob.PiglinEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(Piglin.class)
|
@Mixin(PiglinEntity.class)
|
||||||
public abstract class PiglinEntityMixin {
|
public abstract class PiglinEntityMixin {
|
||||||
@Inject(method = "holdInOffHand", at = @At(value = "HEAD"), cancellable = true)
|
@Inject(method = "equipToOffHand", at = @At(value = "HEAD"), cancellable = true)
|
||||||
public void cobblemon$isValidBarteringItem(ItemStack stack, CallbackInfo ci) {
|
public void cobblemon$isValidBarteringItem(ItemStack stack, CallbackInfo ci) {
|
||||||
Piglin entity = (Piglin)(Object) this;
|
PiglinEntity entity = (PiglinEntity)(Object) this;
|
||||||
if (stack.is(CobblemonItems.RELIC_COIN_POUCH)) {
|
if (stack.isOf(CobblemonItems.RELIC_COIN_POUCH)) {
|
||||||
entity.setItemSlot(EquipmentSlot.OFFHAND, stack);
|
entity.equipStack(EquipmentSlot.OFFHAND, stack);
|
||||||
entity.setGuaranteedDrop(EquipmentSlot.OFFHAND);
|
entity.updateDropChances(EquipmentSlot.OFFHAND);
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,88 +12,72 @@ import com.cobblemon.mod.common.Cobblemon;
|
|||||||
import com.cobblemon.mod.common.CobblemonItems;
|
import com.cobblemon.mod.common.CobblemonItems;
|
||||||
import com.cobblemon.mod.common.api.events.CobblemonEvents;
|
import com.cobblemon.mod.common.api.events.CobblemonEvents;
|
||||||
import com.cobblemon.mod.common.api.events.item.LeftoversCreatedEvent;
|
import com.cobblemon.mod.common.api.events.item.LeftoversCreatedEvent;
|
||||||
import com.cobblemon.mod.common.api.pokemon.PokemonSpecies;
|
import com.cobblemon.mod.common.api.storage.NoPokemonStoreException;
|
||||||
import com.cobblemon.mod.common.api.storage.party.PartyStore;
|
import com.cobblemon.mod.common.api.storage.party.PartyStore;
|
||||||
import com.cobblemon.mod.common.api.tags.CobblemonItemTags;
|
import com.cobblemon.mod.common.api.tags.CobblemonItemTags;
|
||||||
import com.cobblemon.mod.common.pokedex.scanner.PokedexEntityData;
|
|
||||||
import com.cobblemon.mod.common.pokedex.scanner.ScannableEntity;
|
|
||||||
import com.cobblemon.mod.common.pokemon.FormData;
|
|
||||||
import com.cobblemon.mod.common.pokemon.Gender;
|
|
||||||
import com.cobblemon.mod.common.pokemon.Pokemon;
|
import com.cobblemon.mod.common.pokemon.Pokemon;
|
||||||
import com.cobblemon.mod.common.pokemon.Species;
|
|
||||||
import com.cobblemon.mod.common.util.CompoundTagExtensionsKt;
|
import com.cobblemon.mod.common.util.CompoundTagExtensionsKt;
|
||||||
import com.cobblemon.mod.common.util.CompoundTagUtilities;
|
|
||||||
import com.cobblemon.mod.common.util.DataKeys;
|
import com.cobblemon.mod.common.util.DataKeys;
|
||||||
import com.cobblemon.mod.common.world.gamerules.CobblemonGameRules;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.entity.item.ItemEntity;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.food.FoodProperties;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
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.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Mixin(Player.class)
|
@Mixin(PlayerEntity.class)
|
||||||
public abstract class PlayerMixin extends LivingEntity implements ScannableEntity {
|
public abstract class PlayerMixin extends LivingEntity {
|
||||||
|
|
||||||
@Shadow public abstract CompoundTag getShoulderEntityLeft();
|
@Shadow public abstract NbtCompound getShoulderEntityLeft();
|
||||||
|
|
||||||
@Shadow public abstract CompoundTag getShoulderEntityRight();
|
@Shadow public abstract NbtCompound getShoulderEntityRight();
|
||||||
|
|
||||||
@Shadow public abstract void respawnEntityOnShoulder(CompoundTag entityNbt);
|
@Shadow public abstract void dropShoulderEntity(NbtCompound entityNbt);
|
||||||
|
|
||||||
@Shadow public abstract void setShoulderEntityRight(CompoundTag entityNbt);
|
@Shadow public abstract void setShoulderEntityRight(NbtCompound entityNbt);
|
||||||
|
|
||||||
@Shadow public abstract void setShoulderEntityLeft(CompoundTag entityNbt);
|
@Shadow public abstract void setShoulderEntityLeft(NbtCompound entityNbt);
|
||||||
|
|
||||||
@Shadow public abstract boolean isSpectator();
|
@Shadow public abstract boolean isSpectator();
|
||||||
|
|
||||||
@Shadow public abstract boolean addItem(ItemStack stack);
|
@Shadow public abstract boolean giveItemStack(ItemStack stack);
|
||||||
|
|
||||||
@Shadow public abstract void displayClientMessage(Component message, boolean overlay);
|
@Shadow public abstract void sendMessage(Text message, boolean overlay);
|
||||||
|
|
||||||
|
|
||||||
protected PlayerMixin(EntityType<? extends LivingEntity> p_20966_, Level p_20967_) {
|
protected PlayerMixin(EntityType<? extends LivingEntity> p_20966_, World p_20967_) {
|
||||||
super(p_20966_, p_20967_);
|
super(p_20966_, p_20967_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "respawnEntityOnShoulder", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/EntityType;create(Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/world/level/Level;)Ljava/util/Optional;"), cancellable = true)
|
@Inject(method = "dropShoulderEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityType;getEntityFromNbt(Lnet/minecraft/nbt/NbtCompound;Lnet/minecraft/world/World;)Ljava/util/Optional;"), cancellable = true)
|
||||||
private void cobblemon$removePokemon(CompoundTag nbt, CallbackInfo ci) {
|
private void cobblemon$removePokemon(NbtCompound nbt, CallbackInfo ci) {
|
||||||
if (CompoundTagExtensionsKt.isPokemonEntity(nbt)) {
|
if (CompoundTagExtensionsKt.isPokemonEntity(nbt)) {
|
||||||
final UUID uuid = CompoundTagUtilities.getPokemonID(nbt);
|
final UUID uuid = this.getPokemonID(nbt);
|
||||||
if (CompoundTagUtilities.isShoulderPokemon(this.getShoulderEntityRight())) {
|
if (this.isShoulderPokemon(this.getShoulderEntityRight())) {
|
||||||
final UUID uuidRight = CompoundTagUtilities.getPokemonID(this.getShoulderEntityRight());
|
final UUID uuidRight = this.getPokemonID(this.getShoulderEntityRight());
|
||||||
if (uuid.equals(uuidRight)) {
|
if (uuid.equals(uuidRight)) {
|
||||||
this.recallPokemon(uuidRight);
|
this.recallPokemon(uuidRight);
|
||||||
this.setShoulderEntityRight(new CompoundTag());
|
this.setShoulderEntityRight(new NbtCompound());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (CompoundTagUtilities.isShoulderPokemon(this.getShoulderEntityLeft())) {
|
if (this.isShoulderPokemon(this.getShoulderEntityLeft())) {
|
||||||
final UUID uuidLeft = CompoundTagUtilities.getPokemonID(this.getShoulderEntityLeft());
|
final UUID uuidLeft = this.getPokemonID(this.getShoulderEntityLeft());
|
||||||
if (uuid.equals(uuidLeft)) {
|
if (uuid.equals(uuidLeft)) {
|
||||||
this.recallPokemon(uuidLeft);
|
this.recallPokemon(uuidLeft);
|
||||||
this.setShoulderEntityLeft(new CompoundTag());
|
this.setShoulderEntityLeft(new NbtCompound());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
@@ -101,7 +85,7 @@ public abstract class PlayerMixin extends LivingEntity implements ScannableEntit
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "removeEntitiesOnShoulder",
|
method = "dropShoulderEntities",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "JUMP",
|
value = "JUMP",
|
||||||
opcode = Opcodes.IFGE,
|
opcode = Opcodes.IFGE,
|
||||||
@@ -112,50 +96,61 @@ public abstract class PlayerMixin extends LivingEntity implements ScannableEntit
|
|||||||
)
|
)
|
||||||
private void cobblemon$preventPokemonDropping(CallbackInfo ci) {
|
private void cobblemon$preventPokemonDropping(CallbackInfo ci) {
|
||||||
// We want to allow both of these to forcefully remove the entities
|
// We want to allow both of these to forcefully remove the entities
|
||||||
if (this.isSpectator() || this.isDeadOrDying())
|
if (this.isSpectator() || this.isDead())
|
||||||
return;
|
return;
|
||||||
if (!CompoundTagUtilities.isShoulderPokemon(this.getShoulderEntityLeft())) {
|
if (!this.isShoulderPokemon(this.getShoulderEntityLeft())) {
|
||||||
this.respawnEntityOnShoulder(this.getShoulderEntityLeft());
|
this.dropShoulderEntity(this.getShoulderEntityLeft());
|
||||||
this.setShoulderEntityLeft(new CompoundTag());
|
this.setShoulderEntityLeft(new NbtCompound());
|
||||||
}
|
}
|
||||||
if (!CompoundTagUtilities.isShoulderPokemon(this.getShoulderEntityRight())) {
|
if (!this.isShoulderPokemon(this.getShoulderEntityRight())) {
|
||||||
this.respawnEntityOnShoulder(this.getShoulderEntityRight());
|
this.dropShoulderEntity(this.getShoulderEntityRight());
|
||||||
this.setShoulderEntityRight(new CompoundTag());
|
this.setShoulderEntityRight(new NbtCompound());
|
||||||
}
|
}
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private UUID getPokemonID(NbtCompound nbt) {
|
||||||
|
return nbt.getCompound(DataKeys.POKEMON)
|
||||||
|
.getUuid(DataKeys.POKEMON_UUID);
|
||||||
|
}
|
||||||
|
|
||||||
private void recallPokemon(UUID uuid) {
|
private void recallPokemon(UUID uuid) {
|
||||||
// We need to do this cause the Entity doesn't store a reference to its storage
|
// We need to do this cause the Entity doesn't store a reference to its storage
|
||||||
final PartyStore party = Cobblemon.INSTANCE.getStorage().getParty(this.getUUID(), this.registryAccess());
|
try {
|
||||||
for (Pokemon pokemon : party) {
|
final PartyStore party = Cobblemon.INSTANCE.getStorage().getParty(this.uuid);
|
||||||
if (pokemon.getUuid().equals(uuid)) {
|
for (Pokemon pokemon : party) {
|
||||||
pokemon.recall();
|
if (pokemon.getUuid().equals(uuid)) {
|
||||||
|
pokemon.recall();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (NoPokemonStoreException ignored) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isShoulderPokemon(NbtCompound nbt) {
|
||||||
|
return CompoundTagExtensionsKt.isPokemonEntity(nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "eat",
|
method = "eatFood",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/world/entity/player/Player;getFoodData()Lnet/minecraft/world/food/FoodData;",
|
target = "Lnet/minecraft/entity/player/PlayerEntity;getHungerManager()Lnet/minecraft/entity/player/HungerManager;",
|
||||||
shift = At.Shift.AFTER
|
shift = At.Shift.AFTER
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
public void onEatFood(Level world, ItemStack stack, FoodProperties foodComponent, CallbackInfoReturnable<ItemStack> cir) {
|
public void onEatFood(World world, ItemStack stack, CallbackInfoReturnable<ItemStack> cir) {
|
||||||
if (!level().isClientSide) {
|
if (!getWorld().isClient) {
|
||||||
if (stack.is(CobblemonItemTags.LEAVES_LEFTOVERS) && level().random.nextDouble() < Cobblemon.config.getAppleLeftoversChance()) {
|
if (stack.isIn(CobblemonItemTags.LEAVES_LEFTOVERS) && getWorld().random.nextDouble() < Cobblemon.config.getAppleLeftoversChance()) {
|
||||||
ItemStack leftovers = new ItemStack(CobblemonItems.LEFTOVERS);
|
ItemStack leftovers = new ItemStack(CobblemonItems.LEFTOVERS);
|
||||||
ServerPlayer player = Objects.requireNonNull(getServer()).getPlayerList().getPlayer(uuid);
|
ServerPlayerEntity player = Objects.requireNonNull(getServer()).getPlayerManager().getPlayer(uuid);
|
||||||
assert player != null;
|
assert player != null;
|
||||||
CobblemonEvents.LEFTOVERS_CREATED.postThen(
|
CobblemonEvents.LEFTOVERS_CREATED.postThen(
|
||||||
new LeftoversCreatedEvent(player, leftovers),
|
new LeftoversCreatedEvent(player, leftovers),
|
||||||
leftoversCreatedEvent -> null,
|
leftoversCreatedEvent -> null,
|
||||||
leftoversCreatedEvent -> {
|
leftoversCreatedEvent -> {
|
||||||
if(!player.addItem(leftoversCreatedEvent.getLeftovers())) {
|
if(!player.giveItemStack(leftoversCreatedEvent.getLeftovers())) {
|
||||||
var itemPos = player.getLookAngle().scale(0.5f).add(position());
|
var itemPos = player.getRotationVector().multiply(0.5).add(getPos());
|
||||||
level().addFreshEntity(new ItemEntity(level(), itemPos.x(), itemPos.y(), itemPos.z(), leftoversCreatedEvent.getLeftovers()));
|
getWorld().spawnEntity(new ItemEntity(getWorld(), itemPos.getX(), itemPos.getY(), itemPos.getZ(), leftoversCreatedEvent.getLeftovers()));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -163,61 +158,4 @@ public abstract class PlayerMixin extends LivingEntity implements ScannableEntit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "isInvulnerableTo", at = @At("HEAD"), cancellable = true)
|
|
||||||
public void isInvulnerableTo(DamageSource source, CallbackInfoReturnable<Boolean> ci) {
|
|
||||||
if (!level().isClientSide) {
|
|
||||||
ServerPlayer player = (ServerPlayer)(Object)this;
|
|
||||||
boolean invulnerableInBattle = this.level().getGameRules().getBoolean(CobblemonGameRules.BATTLE_INVULNERABILITY);
|
|
||||||
boolean inBattle = Cobblemon.INSTANCE.getBattleRegistry().getBattleByParticipatingPlayer(player) != null;
|
|
||||||
if (invulnerableInBattle && inBattle) {
|
|
||||||
ci.setReturnValue(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override @Nullable
|
|
||||||
public PokedexEntityData resolvePokemonScan() {
|
|
||||||
if(CompoundTagUtilities.isShoulderPokemon(this.getShoulderEntityRight())){
|
|
||||||
return getDataFromShoulderPokemon(this.getShoulderEntityRight());
|
|
||||||
}
|
|
||||||
if(CompoundTagUtilities.isShoulderPokemon(this.getShoulderEntityLeft())){
|
|
||||||
return getDataFromShoulderPokemon(this.getShoulderEntityLeft());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable @Unique
|
|
||||||
private PokedexEntityData getDataFromShoulderPokemon(CompoundTag shoulderTag) {
|
|
||||||
CompoundTag pokemonTag = shoulderTag.getCompound(DataKeys.POKEMON);
|
|
||||||
if(pokemonTag.isEmpty()) return null;
|
|
||||||
Species species = PokemonSpecies.INSTANCE.getByIdentifier(ResourceLocation.parse(pokemonTag.getString(DataKeys.POKEMON_SPECIES_IDENTIFIER)));
|
|
||||||
if(species == null) return null;
|
|
||||||
String formId = pokemonTag.getString(DataKeys.POKEMON_FORM_ID);
|
|
||||||
FormData form = species.getStandardForm();
|
|
||||||
List<FormData> formList = species.getForms().stream().filter(it -> it.formOnlyShowdownId().equals(formId)).toList();
|
|
||||||
if(!formList.isEmpty()) form = formList.getFirst();
|
|
||||||
if(form == null) return null;
|
|
||||||
String genderString = pokemonTag.getString(DataKeys.POKEMON_GENDER);
|
|
||||||
if(genderString.isEmpty()) return null;
|
|
||||||
Gender gender = Gender.valueOf(genderString);
|
|
||||||
boolean shiny = pokemonTag.getBoolean(DataKeys.POKEMON_SHINY);
|
|
||||||
int level = pokemonTag.getInt(DataKeys.POKEMON_LEVEL);
|
|
||||||
Set<String> aspects = shoulderTag.getList(DataKeys.SHOULDER_ASPECTS, Tag.TAG_STRING).stream().map(Tag::getAsString).collect(Collectors.toSet());
|
|
||||||
|
|
||||||
return new PokedexEntityData(
|
|
||||||
species,
|
|
||||||
form,
|
|
||||||
gender,
|
|
||||||
aspects,
|
|
||||||
shiny,
|
|
||||||
level,
|
|
||||||
this.getUUID()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LivingEntity resolveEntityScan() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.client.render.ClientPlayerIcon;
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.player.AbstractClientPlayer;
|
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
|
||||||
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
|
|
||||||
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(PlayerRenderer.class)
|
|
||||||
public class PlayerRendererMixin {
|
|
||||||
|
|
||||||
@Inject(method = "render", at = @At(value = "TAIL"))
|
|
||||||
public void renderPlayer(AbstractClientPlayer player, float f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) {
|
|
||||||
ClientPlayerIcon.Companion.onRenderPlayer(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,9 +9,9 @@
|
|||||||
package com.cobblemon.mod.common.mixin;
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
import com.cobblemon.mod.common.api.tags.CobblemonBlockTags;
|
import com.cobblemon.mod.common.api.tags.CobblemonBlockTags;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.world.level.block.PointedDripstoneBlock;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.block.PointedDripstoneBlock;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
@@ -21,12 +21,12 @@ import org.spongepowered.asm.mixin.injection.Slice;
|
|||||||
public abstract class PointedDripstoneBlockMixin {
|
public abstract class PointedDripstoneBlockMixin {
|
||||||
|
|
||||||
@Redirect(
|
@Redirect(
|
||||||
method = "canTipGrow(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;)Z",
|
method = "canGrow(Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)Z",
|
||||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;is(Lnet/minecraft/world/level/Block;)Z", ordinal = 0),
|
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isOf(Lnet/minecraft/block/Block;)Z", ordinal = 0),
|
||||||
slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/world/level/block/Blocks;DRIPSTONE_BLOCK:Lnet/minecraft/world/level/Block;"))
|
slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/block/Blocks;DRIPSTONE_BLOCK:Lnet/minecraft/block/Block;"))
|
||||||
)
|
)
|
||||||
private static boolean cobblemon$validateMoonStoneDripstone(BlockState instance, Block block) {
|
private static boolean cobblemon$validateMoonStoneDripstone(BlockState instance, Block block) {
|
||||||
return instance.is(CobblemonBlockTags.DRIPSTONE_GROWABLE);
|
return instance.isIn(CobblemonBlockTags.DRIPSTONE_GROWABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -10,21 +10,21 @@ package com.cobblemon.mod.common.mixin;
|
|||||||
|
|
||||||
import com.cobblemon.mod.common.block.ShearableBlock;
|
import com.cobblemon.mod.common.block.ShearableBlock;
|
||||||
import kotlin.Unit;
|
import kotlin.Unit;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.core.dispenser.ShearsDispenseItemBehavior;
|
import net.minecraft.block.dispenser.ShearsDispenserBehavior;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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;
|
||||||
|
|
||||||
@Mixin(ShearsDispenseItemBehavior.class)
|
@Mixin(ShearsDispenserBehavior.class)
|
||||||
public abstract class ShearsDispenserBehaviorMixin {
|
public abstract class ShearsDispenserBehaviorMixin {
|
||||||
|
|
||||||
// This exists, so we can execute our custom interaction only if no one redirected shears interactions to overwrite the vanilla ones.
|
// This exists, so we can execute our custom interaction only if no one redirected shears interactions to overwrite the vanilla ones.
|
||||||
@Inject(method = "tryShearBeehive", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "tryShearBlock", at = @At("HEAD"), cancellable = true)
|
||||||
private static void cobblemon$tryApricornHarvest(ServerLevel world, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
|
private static void cobblemon$tryApricornHarvest(ServerWorld world, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
|
||||||
final BlockState state = world.getBlockState(pos);
|
final BlockState state = world.getBlockState(pos);
|
||||||
if (state.getBlock() instanceof ShearableBlock shearableBlock) {
|
if (state.getBlock() instanceof ShearableBlock shearableBlock) {
|
||||||
cir.setReturnValue(shearableBlock.attemptShear(world, state, pos, () -> Unit.INSTANCE));
|
cir.setReturnValue(shearableBlock.attemptShear(world, state, pos, () -> Unit.INSTANCE));
|
||||||
|
|||||||
@@ -1,113 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.client.sound.BattleMusicController;
|
|
||||||
import com.cobblemon.mod.common.duck.SoundEngineDuck;
|
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
import com.mojang.blaze3d.audio.Channel;
|
|
||||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
|
||||||
import net.minecraft.client.sounds.ChannelAccess;
|
|
||||||
import net.minecraft.client.sounds.SoundEngine;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
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.CallbackInfo;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Mixin(SoundEngine.class)
|
|
||||||
public abstract class SoundEngineMixin implements SoundEngineDuck {
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
private boolean loaded;
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
private Multimap<SoundSource, SoundInstance> instanceBySource;
|
|
||||||
|
|
||||||
@Shadow @Final
|
|
||||||
private Map<SoundInstance, ChannelAccess.ChannelHandle> instanceToChannel;
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
protected abstract void stop(SoundInstance sound);
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
public abstract boolean isActive(SoundInstance sound);
|
|
||||||
|
|
||||||
/** Resumes the Source belonging to the queried SoundInstance. */
|
|
||||||
private void resume(SoundInstance sound) {
|
|
||||||
ChannelAccess.ChannelHandle sourceManager = this.instanceToChannel.get(sound);
|
|
||||||
if (this.loaded && sourceManager != null) sourceManager.execute(Channel::unpause);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Pauses the Source belonging to the queried SoundInstance. */
|
|
||||||
private void pause(SoundInstance sound) {
|
|
||||||
ChannelAccess.ChannelHandle sourceManager = this.instanceToChannel.get(sound);
|
|
||||||
if (this.loaded && sourceManager != null) sourceManager.execute(Channel::pause);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Resumes the SoundInstance(s) queried by id and/or category. */
|
|
||||||
@Override
|
|
||||||
public void resumeSounds(@Nullable ResourceLocation id, @Nullable SoundSource category) {
|
|
||||||
if (category != null) {
|
|
||||||
this.instanceBySource.get(category).forEach((sound) -> {
|
|
||||||
if (id == null || sound.getLocation().equals(id)) resume(sound);
|
|
||||||
});
|
|
||||||
} else if (id == null) {
|
|
||||||
this.instanceToChannel.keySet().forEach(this::resume);
|
|
||||||
} else {
|
|
||||||
this.instanceToChannel.keySet().forEach(sound -> {
|
|
||||||
if (sound.getLocation().equals(id)) resume(sound);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Pauses the SoundInstances queried by id and/or category. */
|
|
||||||
@Override
|
|
||||||
public void pauseSounds(@Nullable ResourceLocation id, @Nullable SoundSource category) {
|
|
||||||
if (category != null) {
|
|
||||||
this.instanceBySource.get(category).forEach((sound) -> {
|
|
||||||
if (id == null || sound.getLocation().equals(id)) pause(sound);
|
|
||||||
});
|
|
||||||
} else if (id == null) {
|
|
||||||
this.instanceToChannel.keySet().forEach(this::pause);
|
|
||||||
} else {
|
|
||||||
this.instanceToChannel.keySet().forEach(sound -> {
|
|
||||||
if (sound.getLocation().equals(id)) pause(sound);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Allows stopping all SoundInstances that belong to a queried category. */
|
|
||||||
@Inject(method = "stop(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/sounds/SoundSource;)V", at = @At("HEAD"), cancellable = true)
|
|
||||||
public void stopSounds(@Nullable ResourceLocation id, @Nullable SoundSource category, CallbackInfo cb) {
|
|
||||||
if (id == null && category != null) {
|
|
||||||
this.instanceBySource.get(category).forEach(this::stop);
|
|
||||||
cb.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Different behavior for resuming SoundInstances while a BattleMusicInstance is being played. We do not want to resume filtered sounds. */
|
|
||||||
@Inject(method = "resume()V", at = @At("HEAD"), cancellable = true)
|
|
||||||
public void resume(CallbackInfo cb) {
|
|
||||||
if (this.isActive(BattleMusicController.INSTANCE.getMusic())) {
|
|
||||||
this.instanceBySource.values().forEach(sound -> {
|
|
||||||
if (sound == BattleMusicController.INSTANCE.getMusic() || !BattleMusicController.INSTANCE.getFilteredCategories().contains(sound.getSource())) {
|
|
||||||
resume(sound);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cb.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,19 +8,12 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
import com.cobblemon.mod.common.client.sound.BlockEntitySoundTracker;
|
import com.cobblemon.mod.common.client.sound.battle.BattleMusicController;
|
||||||
import com.cobblemon.mod.common.client.sound.EntitySoundTracker;
|
|
||||||
import com.cobblemon.mod.common.client.sound.BattleMusicController;
|
|
||||||
import com.cobblemon.mod.common.client.sound.SoundTracker;
|
|
||||||
import com.cobblemon.mod.common.duck.SoundManagerDuck;
|
import com.cobblemon.mod.common.duck.SoundManagerDuck;
|
||||||
import com.cobblemon.mod.common.duck.SoundEngineDuck;
|
import com.cobblemon.mod.common.duck.SoundSystemDuck;
|
||||||
import net.minecraft.client.resources.sounds.BiomeAmbientSoundsHandler;
|
import net.minecraft.client.sound.*;
|
||||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.client.resources.sounds.UnderwaterAmbientSoundInstances;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.client.sounds.SoundEngine;
|
|
||||||
import net.minecraft.client.sounds.SoundManager;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -33,65 +26,59 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
public abstract class SoundManagerMixin implements SoundManagerDuck {
|
public abstract class SoundManagerMixin implements SoundManagerDuck {
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
public abstract boolean isActive(SoundInstance sound);
|
public abstract boolean isPlaying(SoundInstance sound);
|
||||||
|
|
||||||
@Shadow @Final
|
@Shadow @Final
|
||||||
private SoundEngine soundEngine;
|
private SoundSystem soundSystem;
|
||||||
|
|
||||||
// Never-ending ambient loops are a special exception (they are only initiated once) and should always be paused if filtered.
|
// Never-ending ambient loops are a special exception (they are only initiated once) and should always be paused if filtered.
|
||||||
private boolean isAmbientLoop(SoundInstance sound) {
|
private boolean isAmbientLoop(SoundInstance sound) {
|
||||||
return sound instanceof BiomeAmbientSoundsHandler.LoopSoundInstance || sound instanceof UnderwaterAmbientSoundInstances.UnderwaterAmbientSoundInstance;
|
return sound instanceof BiomeEffectSoundPlayer.MusicLoop || sound instanceof AmbientSoundLoops.Underwater;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean filterCondition(SoundInstance sound) {
|
private boolean filterCondition(SoundInstance sound) {
|
||||||
return !isAmbientLoop(sound) &&
|
return !isAmbientLoop(sound) &&
|
||||||
this.isActive(BattleMusicController.INSTANCE.getMusic()) &&
|
this.isPlaying(BattleMusicController.INSTANCE.getMusic()) &&
|
||||||
BattleMusicController.INSTANCE.getFilteredCategories().contains(sound.getSource());
|
BattleMusicController.INSTANCE.getFilteredCategories().contains(sound.getCategory());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean ambientLoopCondition(SoundInstance sound) {
|
private boolean ambientLoopCondition(SoundInstance sound) {
|
||||||
return isAmbientLoop(sound) &&
|
return isAmbientLoop(sound) &&
|
||||||
this.isActive(BattleMusicController.INSTANCE.getMusic()) &&
|
this.isPlaying(BattleMusicController.INSTANCE.getMusic()) &&
|
||||||
BattleMusicController.INSTANCE.getFilteredCategories().contains(sound.getSource());
|
BattleMusicController.INSTANCE.getFilteredCategories().contains(sound.getCategory());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Pauses the queried SoundInstance(s). If id is null, will pause all sounds belonging to the SoundCategory. */
|
/** Pauses the queried SoundInstance(s). If id is null, will pause all sounds belonging to the SoundCategory. */
|
||||||
@Override
|
@Override
|
||||||
public void pauseSounds(@Nullable ResourceLocation id, @Nullable SoundSource category) {
|
public void pauseSounds(@Nullable Identifier id, @Nullable SoundCategory category) {
|
||||||
((SoundEngineDuck)soundEngine).pauseSounds(id, category);
|
((SoundSystemDuck)soundSystem).pauseSounds(id, category);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resumes the queried SoundInstance(s). If id is null, will resume all sounds belonging to the SoundCategory. */
|
/** Resumes the queried SoundInstance(s). If id is null, will resume all sounds belonging to the SoundCategory. */
|
||||||
@Override
|
@Override
|
||||||
public void resumeSounds(@Nullable ResourceLocation id, @Nullable SoundSource category) {
|
public void resumeSounds(@Nullable Identifier id, @Nullable SoundCategory category) {
|
||||||
((SoundEngineDuck)soundEngine).resumeSounds(id, category);
|
((SoundSystemDuck)soundSystem).resumeSounds(id, category);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Blocks filtered sounds from being played while a BattleMusicInstance is in progress. */
|
/** Blocks filtered sounds from being played while a BattleMusicInstance is in progress. */
|
||||||
@Inject(method = "play(Lnet/minecraft/client/resources/sounds/SoundInstance;)V", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V", at = @At("HEAD"), cancellable = true)
|
||||||
public void playStart(SoundInstance sound, CallbackInfo cb) {
|
public void playStart(SoundInstance sound, CallbackInfo cb) {
|
||||||
if (filterCondition(sound)) cb.cancel();
|
if (filterCondition(sound)) cb.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "playDelayed(Lnet/minecraft/client/resources/sounds/SoundInstance;I)V", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;I)V", at = @At("HEAD"), cancellable = true)
|
||||||
public void playStart(SoundInstance sound, int delay, CallbackInfo cb) {
|
public void playStart(SoundInstance sound, int delay, CallbackInfo cb) {
|
||||||
if (filterCondition(sound)) cb.cancel();
|
if (filterCondition(sound)) cb.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Pauses ambient loops while a BattleMusicInstance is in progress. */
|
/** Pauses ambient loops while a BattleMusicInstance is in progress. */
|
||||||
@Inject(method = "play(Lnet/minecraft/client/resources/sounds/SoundInstance;)V", at = @At("TAIL"))
|
@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V", at = @At("TAIL"))
|
||||||
public void playEnd(SoundInstance sound, CallbackInfo cb) {
|
public void playEnd(SoundInstance sound, CallbackInfo cb) {
|
||||||
if (ambientLoopCondition(sound)) this.pauseSounds(sound.getLocation(), SoundSource.AMBIENT);
|
if (ambientLoopCondition(sound)) this.pauseSounds(sound.getId(), SoundCategory.AMBIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "playDelayed(Lnet/minecraft/client/resources/sounds/SoundInstance;I)V", at = @At("TAIL"))
|
@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;I)V", at = @At("TAIL"))
|
||||||
public void playEnd(SoundInstance sound, int delay, CallbackInfo cb) {
|
public void playEnd(SoundInstance sound, int delay, CallbackInfo cb) {
|
||||||
if (ambientLoopCondition(sound)) this.pauseSounds(sound.getLocation(), SoundSource.AMBIENT);
|
if (ambientLoopCondition(sound)) this.pauseSounds(sound.getId(), SoundCategory.AMBIENT);
|
||||||
}
|
|
||||||
|
|
||||||
/** Clears tracked sounds on the client when disconnected. */
|
|
||||||
@Inject(method = "stop()V", at = @At("TAIL"))
|
|
||||||
public void stop(CallbackInfo cb) {
|
|
||||||
SoundTracker.Companion.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 Cobblemon Contributors
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.client.sound.battle.BattleMusicController;
|
||||||
|
import com.cobblemon.mod.common.duck.SoundSystemDuck;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
import net.minecraft.client.sound.*;
|
||||||
|
import net.minecraft.sound.SoundCategory;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
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.CallbackInfo;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Mixin(SoundSystem.class)
|
||||||
|
public abstract class SoundSystemMixin implements SoundSystemDuck {
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
private boolean started;
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
private Multimap<SoundCategory, SoundInstance> sounds;
|
||||||
|
|
||||||
|
@Shadow @Final
|
||||||
|
private Map<SoundInstance, Channel.SourceManager> sources;
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
protected abstract void stop(SoundInstance sound);
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
public abstract boolean isPlaying(SoundInstance sound);
|
||||||
|
|
||||||
|
/** Resumes the Source belonging to the queried SoundInstance. */
|
||||||
|
private void resume(SoundInstance sound) {
|
||||||
|
Channel.SourceManager sourceManager = this.sources.get(sound);
|
||||||
|
if (this.started && sourceManager != null) sourceManager.run(Source::resume);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Pauses the Source belonging to the queried SoundInstance. */
|
||||||
|
private void pause(SoundInstance sound) {
|
||||||
|
Channel.SourceManager sourceManager = this.sources.get(sound);
|
||||||
|
if (this.started && sourceManager != null) sourceManager.run(Source::pause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Resumes the SoundInstance(s) queried by id and/or category. */
|
||||||
|
@Override
|
||||||
|
public void resumeSounds(@Nullable Identifier id, @Nullable SoundCategory category) {
|
||||||
|
if (category != null) {
|
||||||
|
this.sounds.get(category).forEach((sound) -> {
|
||||||
|
if (id == null || sound.getId().equals(id)) resume(sound);
|
||||||
|
});
|
||||||
|
} else if (id == null) {
|
||||||
|
this.sources.keySet().forEach(this::resume);
|
||||||
|
} else {
|
||||||
|
this.sources.keySet().forEach(sound -> {
|
||||||
|
if (sound.getId().equals(id)) resume(sound);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Pauses the SoundInstances queried by id and/or category. */
|
||||||
|
@Override
|
||||||
|
public void pauseSounds(@Nullable Identifier id, @Nullable SoundCategory category) {
|
||||||
|
if (category != null) {
|
||||||
|
this.sounds.get(category).forEach((sound) -> {
|
||||||
|
if (id == null || sound.getId().equals(id)) pause(sound);
|
||||||
|
});
|
||||||
|
} else if (id == null) {
|
||||||
|
this.sources.keySet().forEach(this::pause);
|
||||||
|
} else {
|
||||||
|
this.sources.keySet().forEach(sound -> {
|
||||||
|
if (sound.getId().equals(id)) pause(sound);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Allows stopping all SoundInstances that belong to a queried category. */
|
||||||
|
@Inject(method = "stopSounds(Lnet/minecraft/util/Identifier;Lnet/minecraft/sound/SoundCategory;)V", at = @At("HEAD"), cancellable = true)
|
||||||
|
public void stopSounds(@Nullable Identifier id, @Nullable SoundCategory category, CallbackInfo cb) {
|
||||||
|
if (id == null && category != null) {
|
||||||
|
this.sounds.get(category).forEach(this::stop);
|
||||||
|
cb.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Different behavior for resuming SoundInstances while a BattleMusicInstance is being played. We do not want to resume filtered sounds. */
|
||||||
|
@Inject(method = "resumeAll()V", at = @At("HEAD"), cancellable = true)
|
||||||
|
public void resumeAll(CallbackInfo cb) {
|
||||||
|
if (this.isPlaying(BattleMusicController.INSTANCE.getMusic())) {
|
||||||
|
this.sounds.values().forEach(sound -> {
|
||||||
|
if (sound == BattleMusicController.INSTANCE.getMusic() || !BattleMusicController.INSTANCE.getFilteredCategories().contains(sound.getCategory())) {
|
||||||
|
resume(sound);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cb.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,23 +10,23 @@ package com.cobblemon.mod.common.mixin;
|
|||||||
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
import net.minecraft.structure.pool.StructurePool;
|
||||||
|
import net.minecraft.structure.pool.StructurePoolElement;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Mutable;
|
import org.spongepowered.asm.mixin.Mutable;
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
|
|
||||||
|
|
||||||
@Mixin(StructureTemplatePool.class)
|
@Mixin(StructurePool.class)
|
||||||
public interface StructurePoolAccessor {
|
public interface StructurePoolAccessor {
|
||||||
@Accessor("rawTemplates")
|
@Accessor("elementCounts")
|
||||||
List<Pair<StructurePoolElement, Integer>> getElementCounts();
|
List<Pair<StructurePoolElement, Integer>> getElementCounts();
|
||||||
|
|
||||||
@Mutable
|
@Mutable
|
||||||
@Accessor("rawTemplates")
|
@Accessor("elementCounts")
|
||||||
void setElementCounts(List<Pair<StructurePoolElement, Integer>> elementCounts);
|
void setElementCounts(List<Pair<StructurePoolElement, Integer>> elementCounts);
|
||||||
|
|
||||||
@Accessor("templates")
|
@Accessor("elements")
|
||||||
ObjectArrayList<StructurePoolElement> getElements();
|
ObjectArrayList<StructurePoolElement> getElements();
|
||||||
}
|
}
|
||||||
+101
-49
@@ -9,45 +9,47 @@
|
|||||||
package com.cobblemon.mod.common.mixin;
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
import com.cobblemon.mod.common.world.CobblemonStructureIDs;
|
import com.cobblemon.mod.common.world.CobblemonStructureIDs;
|
||||||
import com.llamalad7.mixinextras.sugar.Local;
|
import net.minecraft.registry.Registry;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.structure.PoolStructurePiece;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.structure.StructureTemplateManager;
|
||||||
import net.minecraft.util.RandomSource;
|
import net.minecraft.structure.pool.*;
|
||||||
import net.minecraft.world.level.LevelHeightAccessor;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
import net.minecraft.util.math.random.Random;
|
||||||
import net.minecraft.world.level.levelgen.RandomState;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.level.levelgen.structure.PoolElementStructurePiece;
|
import net.minecraft.world.HeightLimitView;
|
||||||
import net.minecraft.world.level.levelgen.structure.pools.*;
|
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||||
import net.minecraft.world.level.levelgen.structure.pools.alias.PoolAliasLookup;
|
import net.minecraft.world.gen.noise.NoiseConfig;
|
||||||
import net.minecraft.world.level.levelgen.structure.templatesystem.LiquidSettings;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
|
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
||||||
import org.apache.commons.lang3.mutable.MutableObject;
|
import org.apache.commons.lang3.mutable.MutableObject;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Mutable;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
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.ModifyVariable;
|
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Mixin(JigsawPlacement.Placer.class)
|
@Mixin(StructurePoolBasedGenerator.StructurePoolGenerator.class)
|
||||||
public abstract class StructurePoolGeneratorMixin {
|
public abstract class StructurePoolGeneratorMixin {
|
||||||
|
@Final
|
||||||
|
@Mutable
|
||||||
|
@Shadow Deque<StructurePoolBasedGenerator.ShapedPoolStructurePiece> structurePieces;
|
||||||
|
|
||||||
Map<String, Integer> generatedStructureGroupCounts;
|
Map<String, Integer> generatedStructureGroupCounts;
|
||||||
|
|
||||||
private static final Map<String, Integer> structureMaxes;
|
private static final Map<String, Integer> structureMaxes;
|
||||||
private static final Map<ResourceLocation, Set<String>> structureGroups = new HashMap<>();
|
private static final Map<Identifier, Set<String>> structureGroups = new HashMap<>();
|
||||||
static {
|
static {
|
||||||
String pokecenter = "pokecenter";
|
String pokecenter = "pokecenter";
|
||||||
String berry = "berry_farm";
|
String berry = "berry_farm";
|
||||||
|
|
||||||
structureGroups.put(CobblemonStructureIDs.VILLAGE_PLAINS_POKECENTER, Set.of(pokecenter));
|
structureGroups.put(CobblemonStructureIDs.PLAINS_POKECENTER, Set.of(pokecenter));
|
||||||
structureGroups.put(CobblemonStructureIDs.VILLAGE_DESERT_POKECENTER, Set.of(pokecenter));
|
structureGroups.put(CobblemonStructureIDs.DESERT_POKECENTER, Set.of(pokecenter));
|
||||||
structureGroups.put(CobblemonStructureIDs.VILLAGE_SAVANNA_POKECENTER, Set.of(pokecenter));
|
structureGroups.put(CobblemonStructureIDs.SAVANNA_POKECENTER, Set.of(pokecenter));
|
||||||
structureGroups.put(CobblemonStructureIDs.VILLAGE_SNOWY_POKECENTER, Set.of(pokecenter));
|
structureGroups.put(CobblemonStructureIDs.SNOWY_POKECENTER, Set.of(pokecenter));
|
||||||
structureGroups.put(CobblemonStructureIDs.VILLAGE_TAIGA_POKECENTER, Set.of(pokecenter));
|
structureGroups.put(CobblemonStructureIDs.TAIGA_POKECENTER, Set.of(pokecenter));
|
||||||
|
|
||||||
structureGroups.put(CobblemonStructureIDs.SAVANNA_BERRY_SMALL, Set.of(berry));
|
structureGroups.put(CobblemonStructureIDs.SAVANNA_BERRY_SMALL, Set.of(berry));
|
||||||
structureGroups.put(CobblemonStructureIDs.SAVANNA_BERRY_LARGE, Set.of(berry));
|
structureGroups.put(CobblemonStructureIDs.SAVANNA_BERRY_LARGE, Set.of(berry));
|
||||||
@@ -73,11 +75,11 @@ public abstract class StructurePoolGeneratorMixin {
|
|||||||
structureMaxes = Collections.unmodifiableMap(aMap);
|
structureMaxes = Collections.unmodifiableMap(aMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getGroups(ResourceLocation structureIdentifier) {
|
public Set<String> getGroups(Identifier structureIdentifier) {
|
||||||
return structureGroups.getOrDefault(structureIdentifier, Set.of());
|
return structureGroups.getOrDefault(structureIdentifier, Set.of());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasReachedMaximum(ResourceLocation structureIdentifier) {
|
public boolean hasReachedMaximum(Identifier structureIdentifier) {
|
||||||
Set<String> groups = getGroups(structureIdentifier);
|
Set<String> groups = getGroups(structureIdentifier);
|
||||||
for (String group : groups) {
|
for (String group : groups) {
|
||||||
int count = generatedStructureGroupCounts.getOrDefault(group, 0);
|
int count = generatedStructureGroupCounts.getOrDefault(group, 0);
|
||||||
@@ -89,7 +91,7 @@ public abstract class StructurePoolGeneratorMixin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void incrementStructureCount(ResourceLocation structureIdentifier) {
|
public void incrementStructureCount(Identifier structureIdentifier) {
|
||||||
Set<String> groups = getGroups(structureIdentifier);
|
Set<String> groups = getGroups(structureIdentifier);
|
||||||
for (String group : groups) {
|
for (String group : groups) {
|
||||||
generatedStructureGroupCounts.put(group, generatedStructureGroupCounts.getOrDefault(group, 0) + 1);
|
generatedStructureGroupCounts.put(group, generatedStructureGroupCounts.getOrDefault(group, 0) + 1);
|
||||||
@@ -97,17 +99,17 @@ public abstract class StructurePoolGeneratorMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "<init>", at = @At("RETURN"))
|
@Inject(method = "<init>", at = @At("RETURN"))
|
||||||
private void onStructurePoolGeneratorCreation(Registry<StructureTemplatePool> registry, int maxSize, ChunkGenerator chunkGenerator, StructureTemplateManager structureTemplateManager, List<? super PoolElementStructurePiece> children, RandomSource random, CallbackInfo ci) {
|
private void onStructurePoolGeneratorCreation(Registry<StructurePool> registry, int maxSize, ChunkGenerator chunkGenerator, StructureTemplateManager structureTemplateManager, List<? super PoolStructurePiece> children, Random random, CallbackInfo ci) {
|
||||||
generatedStructureGroupCounts = new HashMap<>();
|
generatedStructureGroupCounts = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModifyVariable(method = "tryPlacingChildren", at = @At("STORE"), ordinal = 1)
|
@ModifyVariable(method = "generatePiece", at = @At("STORE"), ordinal = 1)
|
||||||
private Iterator<StructurePoolElement> reduceStructurePoolElementIterator(Iterator<StructurePoolElement> iterator) {
|
private Iterator<StructurePoolElement> reduceStructurePoolElementIterator(Iterator<StructurePoolElement> iterator) {
|
||||||
List<StructurePoolElement> reducedList = new ArrayList<>();
|
List<StructurePoolElement> reducedList = new ArrayList<>();
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
StructurePoolElement structure = iterator.next();
|
StructurePoolElement structure = iterator.next();
|
||||||
ResourceLocation structurePieceLocationKey = getCobblemonOnlyLocation(structure);
|
Identifier structurePieceLocationKey = getCobblemonOnlyLocation(structure);
|
||||||
if (structurePieceLocationKey == null) {
|
if (structurePieceLocationKey == null) {
|
||||||
reducedList.add(structure);
|
reducedList.add(structure);
|
||||||
continue;
|
continue;
|
||||||
@@ -121,27 +123,55 @@ public abstract class StructurePoolGeneratorMixin {
|
|||||||
return reducedList.iterator();
|
return reducedList.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "tryPlacingChildren", at = @At(value = "NEW", target = "net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
|
@ModifyVariable(method = "generatePiece", at = @At("STORE"), ordinal = 1)
|
||||||
private void afterTryPlacingChildren(
|
private PoolStructurePiece injected(PoolStructurePiece poolStructurePiece) {
|
||||||
PoolElementStructurePiece poolElementStructurePiece,
|
Identifier structureLocationKey = getCobblemonOnlyLocation(poolStructurePiece.getPoolElement());
|
||||||
MutableObject<VoxelShape> mutableObject,
|
|
||||||
int i,
|
|
||||||
boolean bl,
|
|
||||||
LevelHeightAccessor levelHeightAccessor,
|
|
||||||
RandomState randomState,
|
|
||||||
PoolAliasLookup poolAliasLookup,
|
|
||||||
LiquidSettings liquidSettings,
|
|
||||||
CallbackInfo ci,
|
|
||||||
@Local(ordinal = 1) StructurePoolElement structurePoolElement
|
|
||||||
) {
|
|
||||||
ResourceLocation structureLocationKey = getCobblemonOnlyLocation(structurePoolElement);
|
|
||||||
if (structureLocationKey != null) {
|
if (structureLocationKey != null) {
|
||||||
incrementStructureCount(structureLocationKey);
|
incrementStructureCount(structureLocationKey);
|
||||||
}
|
}
|
||||||
|
return poolStructurePiece;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ResourceLocation getCobblemonOnlyLocation(StructurePoolElement structurePoolElement) {
|
// This doesn't SEEM necessary? It appears to work without.
|
||||||
ResourceLocation location = getLocationIfAvailable(structurePoolElement);
|
@Inject(method = "generatePiece", at = @At("HEAD"))
|
||||||
|
private void beforeGeneratePiece(PoolStructurePiece piece, MutableObject<VoxelShape> pieceShape, int minY, boolean modifyBoundingBox, HeightLimitView world, NoiseConfig noiseConfig, CallbackInfo ci) {
|
||||||
|
// Identifier structureLocationKey = getCobblemonOnlyLocation(piece.getPoolElement());
|
||||||
|
//
|
||||||
|
// if (structureLocationKey != null) {
|
||||||
|
// Integer currentlyGenerated = generatedStructureCounts.get(structureLocationKey);
|
||||||
|
// if (currentlyGenerated == null) currentlyGenerated = 0;
|
||||||
|
// generatedStructureCounts.put(structureLocationKey, currentlyGenerated + 1);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// List<StructurePoolBasedGenerator.ShapedPoolStructurePiece> reducedStructurePiecesList = structurePieces.stream().toList();
|
||||||
|
//
|
||||||
|
// for (Identifier maxStructureLocationKey : structureMaxes.keySet()) {
|
||||||
|
// Integer maxAllowed = structureMaxes.get(maxStructureLocationKey);
|
||||||
|
//
|
||||||
|
// Integer currentlyGenerated = generatedStructureCounts.get(maxStructureLocationKey);
|
||||||
|
// if (currentlyGenerated == null) currentlyGenerated = 0;
|
||||||
|
// if (currentlyGenerated < maxAllowed) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //Already have max so need to remove
|
||||||
|
// reducedStructurePiecesList = reducedStructurePiecesList.stream()
|
||||||
|
// .filter(shapedStructurePiece -> {
|
||||||
|
// Identifier locationKey = getCobblemonOnlyLocation(shapedStructurePiece.piece.getPoolElement());
|
||||||
|
// if (locationKey == null) {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return !locationKey.equals(maxStructureLocationKey);
|
||||||
|
// })
|
||||||
|
// .collect(Collectors.toList());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// structurePieces = new ArrayDeque<>(reducedStructurePiecesList);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Identifier getCobblemonOnlyLocation(StructurePoolElement structurePoolElement) {
|
||||||
|
Identifier location = getLocationIfAvailable(structurePoolElement);
|
||||||
if (location == null) return null;
|
if (location == null) return null;
|
||||||
|
|
||||||
if (!location.getNamespace().equals("cobblemon")) return null;
|
if (!location.getNamespace().equals("cobblemon")) return null;
|
||||||
@@ -149,17 +179,39 @@ public abstract class StructurePoolGeneratorMixin {
|
|||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ResourceLocation getLocationIfAvailable(StructurePoolElement structurePoolElement) {
|
private static Identifier getLocationIfAvailable(StructurePoolElement structurePoolElement) {
|
||||||
if (structurePoolElement instanceof LegacySinglePoolElement legacySinglePoolElement) {
|
if (structurePoolElement instanceof LegacySinglePoolElement legacySinglePoolElement) {
|
||||||
if (legacySinglePoolElement.template.left().isEmpty()) return null;
|
if (legacySinglePoolElement.location.left().isEmpty()) return null;
|
||||||
|
|
||||||
return legacySinglePoolElement.template.left().get();
|
return legacySinglePoolElement.location.left().get();
|
||||||
} else if (structurePoolElement instanceof SinglePoolElement singlePoolElement) {
|
} else if (structurePoolElement instanceof SinglePoolElement singlePoolElement) {
|
||||||
if (singlePoolElement.template.left().isEmpty()) return null;
|
if (singlePoolElement.location.left().isEmpty()) return null;
|
||||||
|
|
||||||
return singlePoolElement.template.left().get();
|
return singlePoolElement.location.left().get();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// private List<StructurePoolElement> removeInstanceOfLocationKeyFrom(List<StructurePoolElement> structureList, Integer allowedNumberOfInstances, Identifier locationKey) {
|
||||||
|
// List<StructurePoolElement> reducedList = new ArrayList<>();
|
||||||
|
// int instancesFound = 0;
|
||||||
|
//
|
||||||
|
// for (StructurePoolElement structurePoolElement: structureList) {
|
||||||
|
// Identifier structureKey = getCobblemonOnlyLocation(structurePoolElement);
|
||||||
|
// if (structureKey == null || !structureKey.equals(locationKey)) {
|
||||||
|
// reducedList.add(structurePoolElement);
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (instancesFound >= allowedNumberOfInstances) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// reducedList.add(structurePoolElement);
|
||||||
|
// instancesFound++;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return reducedList;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|||||||
+2
-2
@@ -12,8 +12,8 @@ import com.cobblemon.mod.common.bridges.StructureProcessorListBridge;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
|
import net.minecraft.structure.processor.StructureProcessor;
|
||||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList;
|
import net.minecraft.structure.processor.StructureProcessorList;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Mutable;
|
import org.spongepowered.asm.mixin.Mutable;
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.Cobblemon;
|
|
||||||
import com.cobblemon.mod.common.world.gamerules.CobblemonGameRules;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
import net.minecraft.world.entity.ai.targeting.TargetingConditions;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
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(TargetingConditions.class)
|
|
||||||
public class TargetingConditionsMixin {
|
|
||||||
|
|
||||||
@Inject(method = "test", at = @At("HEAD"), cancellable = true)
|
|
||||||
public void test(@Nullable LivingEntity baseEntity, LivingEntity targetEntity, CallbackInfoReturnable<Boolean> ci) {
|
|
||||||
if (targetEntity instanceof ServerPlayer player) {
|
|
||||||
boolean canTargetInBattle = player.level().getGameRules().getBoolean(CobblemonGameRules.MOB_TARGET_IN_BATTLE);
|
|
||||||
boolean targetInBattle = Cobblemon.INSTANCE.getBattleRegistry().getBattleByParticipatingPlayer(player) != null;
|
|
||||||
if (!canTargetInBattle && targetInBattle) ci.setReturnValue(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.Cobblemon;
|
|
||||||
import com.cobblemon.mod.common.CobblemonVillagerProfessions;
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
|
||||||
import kotlin.Pair;
|
|
||||||
import net.minecraft.ChatFormatting;
|
|
||||||
import net.minecraft.client.model.EntityModel;
|
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
|
||||||
import net.minecraft.client.renderer.RenderType;
|
|
||||||
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
|
||||||
import net.minecraft.client.renderer.entity.layers.RenderLayer;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
import net.minecraft.world.entity.monster.ZombieVillager;
|
|
||||||
import net.minecraft.world.entity.npc.Villager;
|
|
||||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
|
||||||
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(RenderLayer.class)
|
|
||||||
public abstract class VillagerProfessionLayerMixin {
|
|
||||||
@Inject(method = "renderColoredCutoutModel", at = @At(value = "HEAD"), cancellable = true)
|
|
||||||
private static <T extends LivingEntity> void cobblemon$renderVillagerProfessionLayer(EntityModel<T> entityModel, ResourceLocation resourceLocation, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, T livingEntity, int j, CallbackInfo ci) {
|
|
||||||
if (resourceLocation.getNamespace().equals(Cobblemon.MODID)) {
|
|
||||||
VillagerProfession profession = null;
|
|
||||||
boolean isZombie = false;
|
|
||||||
|
|
||||||
if (livingEntity instanceof Villager) profession = ((Villager) livingEntity).getVillagerData().getProfession();
|
|
||||||
if (livingEntity instanceof ZombieVillager) {
|
|
||||||
profession = ((ZombieVillager) livingEntity).getVillagerData().getProfession();
|
|
||||||
isZombie = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pair<String, String[]> override = CobblemonVillagerProfessions.INSTANCE.getNameTagOverride(profession);
|
|
||||||
if (profession != null && override != null) {
|
|
||||||
String entityName = ChatFormatting.stripFormatting(livingEntity.getName().getString());
|
|
||||||
boolean nameMatches = false;
|
|
||||||
for (String name: override.getSecond())
|
|
||||||
if (entityName.endsWith(name)) {
|
|
||||||
nameMatches = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (nameMatches && resourceLocation.equals(getProfessionResourceLocation(resourceLocation.getNamespace(), ResourceLocation.parse(profession.name()).getPath(), isZombie))) {
|
|
||||||
ResourceLocation textureLocation = getProfessionResourceLocation(resourceLocation.getNamespace(), override.getFirst(), isZombie);
|
|
||||||
VertexConsumer vertexConsumer = multiBufferSource.getBuffer(RenderType.entityCutoutNoCull(textureLocation));
|
|
||||||
entityModel.renderToBuffer(poseStack, vertexConsumer, i, LivingEntityRenderer.getOverlayCoords(livingEntity, 0.0F), j);
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ResourceLocation getProfessionResourceLocation(String namespace, String profession, Boolean isZombie) {
|
|
||||||
return ResourceLocation.fromNamespaceAndPath(namespace, "textures/entity/" + (isZombie ? "zombie_villager" : "villager") + "/profession/" + profession + ".png");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,14 +8,14 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.accessor;
|
package com.cobblemon.mod.common.mixin.accessor;
|
||||||
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
@Mixin(Entity.class)
|
@Mixin(Entity.class)
|
||||||
public interface AccessorEntity {
|
public interface AccessorEntity {
|
||||||
|
|
||||||
@Accessor("eyeHeight")
|
@Accessor("standingEyeHeight")
|
||||||
void standingEyeHeight(float standingEyeHeight);
|
void standingEyeHeight(float standingEyeHeight);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.accessor;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.biome.Biome;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
|
||||||
|
|
||||||
@Mixin(Biome.class)
|
|
||||||
public interface BiomeAccessor {
|
|
||||||
@Accessor("climateSettings")
|
|
||||||
Biome.ClimateSettings getClimateSettings();
|
|
||||||
}
|
|
||||||
+5
-5
@@ -8,16 +8,16 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.accessor;
|
package com.cobblemon.mod.common.mixin.accessor;
|
||||||
|
|
||||||
import net.minecraft.world.entity.vehicle.Boat;
|
import net.minecraft.entity.vehicle.BoatEntity;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
@Mixin(Boat.class)
|
@Mixin(BoatEntity.class)
|
||||||
public interface BoatEntityAccessor {
|
public interface BoatEntityAccessor {
|
||||||
|
|
||||||
@Accessor("lastYd")
|
@Accessor
|
||||||
void setFallVelocity(double fallVelocity);
|
void setFallVelocity(double fallVelocity);
|
||||||
|
|
||||||
@Accessor("status")
|
@Accessor
|
||||||
Boat.Status getLocation();
|
BoatEntity.Location getLocation();
|
||||||
}
|
}
|
||||||
|
|||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.accessor;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.components.AbstractSelectionList;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
|
||||||
|
|
||||||
@Mixin(AbstractSelectionList.class)
|
|
||||||
public interface EntryListWidgetAccessor {
|
|
||||||
@Accessor("renderHeader")
|
|
||||||
boolean getRenderHeader();
|
|
||||||
}
|
|
||||||
+5
-5
@@ -8,15 +8,15 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.accessor;
|
package com.cobblemon.mod.common.mixin.accessor;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.InputConstants;
|
import net.minecraft.client.option.KeyBinding;
|
||||||
import net.minecraft.client.KeyMapping;
|
import net.minecraft.client.util.InputUtil;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
@Mixin(KeyMapping.class)
|
@Mixin(KeyBinding.class)
|
||||||
public interface KeyBindingAccessor {
|
public interface KeyBindingAccessor {
|
||||||
|
|
||||||
@Accessor("key")
|
@Accessor("boundKey")
|
||||||
InputConstants.Key boundKey();
|
InputUtil.Key boundKey();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -8,17 +8,17 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.accessor;
|
package com.cobblemon.mod.common.mixin.accessor;
|
||||||
|
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
@Mixin(MobEffectInstance.class)
|
@Mixin(StatusEffectInstance.class)
|
||||||
public interface StatusEffectInstanceAccessor {
|
public interface StatusEffectInstanceAccessor {
|
||||||
|
|
||||||
@Accessor
|
@Accessor
|
||||||
void setAmplifier(int amplifier);
|
void setAmplifier(int amplifier);
|
||||||
|
|
||||||
@Accessor("visible")
|
@Accessor
|
||||||
void setShowParticles(boolean showParticles);
|
void setShowParticles(boolean showParticles);
|
||||||
|
|
||||||
@Accessor
|
@Accessor
|
||||||
|
|||||||
-34
@@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.client;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.client.CobblemonClient;
|
|
||||||
import com.cobblemon.mod.common.pokedex.scanner.PokedexUsageContext;
|
|
||||||
import net.minecraft.client.player.AbstractClientPlayer;
|
|
||||||
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(AbstractClientPlayer.class)
|
|
||||||
public class AbstractClientPlayerMixin {
|
|
||||||
@Inject(
|
|
||||||
method = "getFieldOfViewModifier()F",
|
|
||||||
at = @At(
|
|
||||||
value = "HEAD"
|
|
||||||
),
|
|
||||||
cancellable = true
|
|
||||||
)
|
|
||||||
public void cobblemon$getPokedexFovMultiplier(CallbackInfoReturnable<Float> cir) {
|
|
||||||
PokedexUsageContext usageContext = CobblemonClient.INSTANCE.getPokedexUsageContext();
|
|
||||||
if (usageContext.getScanningGuiOpen()) {
|
|
||||||
cir.setReturnValue(usageContext.getFovMultiplier());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.client;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.client.gui.ScrollingWidget;
|
|
||||||
import net.minecraft.client.gui.components.AbstractSelectionList;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Constant;
|
|
||||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
|
||||||
|
|
||||||
@Mixin(AbstractSelectionList.class)
|
|
||||||
public abstract class EntryListWidgetMixin {
|
|
||||||
|
|
||||||
@SuppressWarnings("ConstantValue")
|
|
||||||
@ModifyConstant(method = "getEntryAtPosition", constant = @Constant(intValue = 4))
|
|
||||||
public int cobblemon$adjustOnlyIfNecessary(int input) {
|
|
||||||
if(ScrollingWidget.class.isInstance(this)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -9,18 +9,18 @@
|
|||||||
package com.cobblemon.mod.common.mixin.entity;
|
package com.cobblemon.mod.common.mixin.entity;
|
||||||
|
|
||||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||||
import net.minecraft.world.entity.TamableAnimal;
|
import net.minecraft.entity.passive.TameableEntity;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.World;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
@Mixin(TamableAnimal.class)
|
@Mixin(TameableEntity.class)
|
||||||
public class TameableEntityMixin {
|
public class TameableEntityMixin {
|
||||||
|
|
||||||
@Redirect(method = "die", at = @At(value = "FIELD", target = "Lnet/minecraft/world/level/Level;isClientSide:Z"))
|
@Redirect(method = "onDeath", at = @At(value = "FIELD", target = "Lnet/minecraft/world/World;isClient:Z"))
|
||||||
public boolean cobblemon$checkIfPokemonBeforeSendingMessage(Level world) {
|
public boolean cobblemon$checkIfPokemonBeforeSendingMessage(World world) {
|
||||||
return world.isClientSide || (this.getClass().isAssignableFrom(PokemonEntity.class));
|
return world.isClient || (this.getClass().isAssignableFrom(PokemonEntity.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.invoker;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.integration.AdornCompatibility;
|
|
||||||
import juuxel.adorn.block.variant.BlockVariantSet;
|
|
||||||
import juuxel.adorn.block.variant.BlockVariantSets;
|
|
||||||
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.CallbackInfo;
|
|
||||||
|
|
||||||
//This is a yucky hack but better than what we were doing before
|
|
||||||
@Mixin(BlockVariantSets.class)
|
|
||||||
public abstract class AdornRegisterInvoker {
|
|
||||||
@Final
|
|
||||||
@Shadow(remap = false)
|
|
||||||
private static List<BlockVariantSet> variantSets;
|
|
||||||
|
|
||||||
@Inject(method = "register()V", at = @At("HEAD"), remap = false)
|
|
||||||
private static void register(CallbackInfo ci) {
|
|
||||||
variantSets.add(new AdornCompatibility());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,11 +8,9 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.invoker;
|
package com.cobblemon.mod.common.mixin.invoker;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.resource.featuretoggle.FeatureFlag;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.sound.BlockSoundGroup;
|
||||||
import net.minecraft.world.level.block.state.properties.BlockSetType;
|
|
||||||
import net.minecraft.world.level.material.MapColor;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||||
|
|
||||||
@@ -20,24 +18,24 @@ import org.spongepowered.asm.mixin.gen.Invoker;
|
|||||||
@Mixin(Blocks.class)
|
@Mixin(Blocks.class)
|
||||||
public interface BlocksInvoker {
|
public interface BlocksInvoker {
|
||||||
|
|
||||||
@Invoker("log")
|
@Invoker("createLogBlock")
|
||||||
static Block createLogBlock(MapColor topMapColor, MapColor sideMapColor) {
|
static PillarBlock createLogBlock(MapColor topMapColor, MapColor sideMapColor) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Invoker("leaves")
|
@Invoker("createLeavesBlock")
|
||||||
static Block createLeavesBlock(SoundType soundGroup) {
|
static LeavesBlock createLeavesBlock(BlockSoundGroup soundGroup) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Invoker("woodenButton")
|
@Invoker("createWoodenButtonBlock")
|
||||||
static Block createWoodenButtonBlock(BlockSetType blockSetType) {
|
static ButtonBlock createWoodenButtonBlock(BlockSetType blockSetType, FeatureFlag... requiredFeatures) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Invoker("flowerPot")
|
@Invoker("createFlowerPotBlock")
|
||||||
static Block createFlowerPotBlock(Block flower) {
|
static FlowerPotBlock createFlowerPotBlock(Block flower, FeatureFlag... requiredFeatures) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,14 +8,14 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.invoker;
|
package com.cobblemon.mod.common.mixin.invoker;
|
||||||
|
|
||||||
import net.minecraft.world.level.GameRules;
|
import net.minecraft.world.GameRules;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||||
|
|
||||||
@Mixin(GameRules.BooleanValue.class)
|
@Mixin(GameRules.BooleanRule.class)
|
||||||
public interface BooleanRuleInvoker {
|
public interface BooleanRuleInvoker {
|
||||||
@Invoker("create")
|
@Invoker("create")
|
||||||
static GameRules.Type<GameRules.BooleanValue> cobblemon$create(boolean initialValue) {
|
static GameRules.Type<GameRules.BooleanRule> cobblemon$create(boolean initialValue) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -8,13 +8,13 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.invoker;
|
package com.cobblemon.mod.common.mixin.invoker;
|
||||||
|
|
||||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||||
|
|
||||||
@Mixin(ClientPacketListener.class)
|
@Mixin(ClientPlayNetworkHandler.class)
|
||||||
public interface ClientPlayNetworkHandlerInvoker {
|
public interface ClientPlayNetworkHandlerInvoker {
|
||||||
@Invoker("postAddEntitySoundInstance")
|
@Invoker
|
||||||
void callPlaySpawnSound(Entity entity);
|
void callPlaySpawnSound(Entity entity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,16 +8,17 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.invoker;
|
package com.cobblemon.mod.common.mixin.invoker;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.DoorBlock;
|
import net.minecraft.block.AbstractBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
import net.minecraft.block.BlockSetType;
|
||||||
import net.minecraft.world.level.block.state.properties.BlockSetType;
|
import net.minecraft.block.DoorBlock;
|
||||||
|
import net.minecraft.sound.SoundEvent;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||||
|
|
||||||
@Mixin(DoorBlock.class)
|
@Mixin(DoorBlock.class)
|
||||||
public interface DoorBlockInvoker {
|
public interface DoorBlockInvoker {
|
||||||
@Invoker("<init>")
|
@Invoker("<init>")
|
||||||
static DoorBlock cobblemon$create(BlockSetType blockSetType, BlockBehaviour.Properties settings) {
|
static DoorBlock cobblemon$create(AbstractBlock.Settings settings, BlockSetType blockSetType) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,13 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.invoker;
|
package com.cobblemon.mod.common.mixin.invoker;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.world.level.block.FireBlock;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import net.minecraft.block.FireBlock;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||||
|
|
||||||
@Mixin(FireBlock.class)
|
@Mixin(FireBlock.class)
|
||||||
public interface FireBlockInvoker {
|
public interface FireBlockInvoker {
|
||||||
@Invoker("setFlammable") void registerNewFlammableBlock(Block block, int burnChance, int spreadChance);
|
@Invoker("registerFlammableBlock") void registerNewFlammableBlock(Block block, int burnChance, int spreadChance);
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-5
@@ -8,16 +8,17 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.invoker;
|
package com.cobblemon.mod.common.mixin.invoker;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.PressurePlateBlock;
|
import net.minecraft.block.AbstractBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
import net.minecraft.block.BlockSetType;
|
||||||
import net.minecraft.world.level.block.state.properties.BlockSetType;
|
import net.minecraft.block.PressurePlateBlock;
|
||||||
|
import net.minecraft.sound.SoundEvent;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||||
|
|
||||||
@Mixin(PressurePlateBlock.class)
|
@Mixin(PressurePlateBlock.class)
|
||||||
public interface PressurePlateBlockInvoker {
|
public interface PressurePlateBlockInvoker {
|
||||||
@Invoker("<init>")
|
@Invoker("<init>")
|
||||||
static PressurePlateBlock cobblemon$create(BlockSetType type, BlockBehaviour.Properties settings) {
|
static PressurePlateBlock cobblemon$create(PressurePlateBlock.ActivationRule type, AbstractBlock.Settings settings, BlockSetType blockSetType) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,16 +8,16 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.invoker;
|
package com.cobblemon.mod.common.mixin.invoker;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.StairBlock;
|
import net.minecraft.block.AbstractBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.block.StairsBlock;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||||
|
|
||||||
@Mixin(StairBlock.class)
|
@Mixin(StairsBlock.class)
|
||||||
public interface StairsBlockInvoker {
|
public interface StairsBlockInvoker {
|
||||||
@Invoker("<init>")
|
@Invoker("<init>")
|
||||||
static StairBlock cobblemon$create(BlockState baseBlockState, BlockBehaviour.Properties settings) {
|
static StairsBlock cobblemon$create(BlockState baseBlockState, AbstractBlock.Settings settings) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-6
@@ -8,16 +8,17 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common.mixin.invoker;
|
package com.cobblemon.mod.common.mixin.invoker;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.TrapDoorBlock;
|
import net.minecraft.block.AbstractBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
import net.minecraft.block.BlockSetType;
|
||||||
import net.minecraft.world.level.block.state.properties.BlockSetType;
|
import net.minecraft.block.TrapdoorBlock;
|
||||||
|
import net.minecraft.sound.SoundEvent;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||||
|
|
||||||
@Mixin(TrapDoorBlock.class)
|
@Mixin(TrapdoorBlock.class)
|
||||||
public interface TrapdoorBlockInvoker {
|
public interface TrapdoorBlockInvoker {
|
||||||
@Invoker("<init>")
|
@Invoker("<init>")
|
||||||
static TrapDoorBlock cobblemon$create(BlockSetType blockSetType, BlockBehaviour.Properties settings) {
|
static TrapdoorBlock cobblemon$create(AbstractBlock.Settings settings, BlockSetType blockSetType) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 Cobblemon Contributors
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.cobblemon.mod.common.mixin.pokeball;
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.item.PokeBallItem;
|
||||||
|
import net.minecraft.client.render.VertexConsumerProvider;
|
||||||
|
import net.minecraft.client.render.item.ItemModels;
|
||||||
|
import net.minecraft.client.render.item.ItemRenderer;
|
||||||
|
import net.minecraft.client.render.model.BakedModel;
|
||||||
|
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||||
|
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
||||||
|
import net.minecraft.client.util.ModelIdentifier;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
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.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(ItemRenderer.class)
|
||||||
|
public abstract class ItemRendererMixin {
|
||||||
|
|
||||||
|
@Shadow @Final private ItemModels models;
|
||||||
|
|
||||||
|
@Shadow public abstract void renderItem(ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model);
|
||||||
|
|
||||||
|
@Inject(method = "getModel", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void cobblemon$bakePokeballModel(ItemStack stack, World world, LivingEntity entity, int seed, CallbackInfoReturnable<BakedModel> cir) {
|
||||||
|
if (stack.getItem() instanceof PokeBallItem pokeBallItem) {
|
||||||
|
BakedModel model = this.models.getModelManager().getModel(new ModelIdentifier(pokeBallItem.getPokeBall().getModel3d(), "inventory"));
|
||||||
|
ClientWorld clientWorld = world instanceof ClientWorld ? (ClientWorld) world : null;
|
||||||
|
BakedModel overriddenModel = model.getOverrides().apply(model, stack, clientWorld, entity, seed);
|
||||||
|
cir.setReturnValue(overriddenModel == null ? this.models.getModelManager().getMissingModel() : overriddenModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V",
|
||||||
|
at = @At("HEAD"),
|
||||||
|
cancellable = true
|
||||||
|
)
|
||||||
|
private void cobblemon$determinePokeballModel(ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, CallbackInfo ci) {
|
||||||
|
boolean shouldBe2d = renderMode == ModelTransformationMode.GUI || renderMode == ModelTransformationMode.FIXED;
|
||||||
|
if (shouldBe2d && stack.getItem() instanceof PokeBallItem pokeBallItem) {
|
||||||
|
BakedModel replacementModel = this.models.getModelManager().getModel(new ModelIdentifier(pokeBallItem.getPokeBall().getModel2d(), "inventory"));
|
||||||
|
if (!model.equals(replacementModel)) {
|
||||||
|
ci.cancel();
|
||||||
|
renderItem(stack, renderMode, leftHanded, matrices, vertexConsumers, light, overlay, replacementModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,24 +9,24 @@
|
|||||||
package com.cobblemon.mod.common.mixin.pokeball;
|
package com.cobblemon.mod.common.mixin.pokeball;
|
||||||
|
|
||||||
import com.cobblemon.mod.common.entity.pokeball.WaterDragModifier;
|
import com.cobblemon.mod.common.entity.pokeball.WaterDragModifier;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.world.entity.projectile.ThrowableProjectile;
|
import net.minecraft.entity.projectile.thrown.ThrownEntity;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.World;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||||
|
|
||||||
@Mixin(ThrowableProjectile.class)
|
@Mixin(ThrownEntity.class)
|
||||||
public abstract class ThrownEntityMixin extends Entity {
|
public abstract class ThrownEntityMixin extends Entity {
|
||||||
|
|
||||||
public ThrownEntityMixin(EntityType<?> type, Level world) {
|
public ThrownEntityMixin(EntityType<?> type, World world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModifyVariable(method = "tick", at = @At("STORE"), ordinal = 0)
|
@ModifyVariable(method = "tick", at = @At("STORE"), ordinal = 0)
|
||||||
private float cobblemon$waterDragModifier(float value) {
|
private float cobblemon$waterDragModifier(float value) {
|
||||||
if (this.isInWater() && this instanceof WaterDragModifier) {
|
if (this.isTouchingWater() && this instanceof WaterDragModifier) {
|
||||||
return ((WaterDragModifier) this).waterDrag();
|
return ((WaterDragModifier) this).waterDrag();
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ object CobblemonBuildDetails {
|
|||||||
|
|
||||||
const val GIT_COMMIT = "{{ gitCommit | default("Not Specified") }}"
|
const val GIT_COMMIT = "{{ gitCommit | default("Not Specified") }}"
|
||||||
const val BRANCH = "{{ branch | default("Not Specified") }}"
|
const val BRANCH = "{{ branch | default("Not Specified") }}"
|
||||||
|
const val TIMESTAMP = "{{ timestamp }}"
|
||||||
|
|
||||||
fun smallCommitHash(): String {
|
fun smallCommitHash(): String {
|
||||||
return this.GIT_COMMIT.substring(0, 7)
|
return this.GIT_COMMIT.substring(0, 7)
|
||||||
|
|||||||
@@ -8,10 +8,10 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common
|
package com.cobblemon.mod.common
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft
|
import net.minecraft.client.MinecraftClient
|
||||||
import net.minecraft.client.resources.model.BakedModel
|
import net.minecraft.client.render.model.BakedModel
|
||||||
import net.minecraft.client.resources.model.ModelResourceLocation
|
import net.minecraft.client.util.ModelIdentifier
|
||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.util.Identifier
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains information for forcing a model to be baked
|
* Contains information for forcing a model to be baked
|
||||||
@@ -20,10 +20,10 @@ import net.minecraft.resources.ResourceLocation
|
|||||||
* @param modelIdentifier The identifier that the BakedModel will be registered to
|
* @param modelIdentifier The identifier that the BakedModel will be registered to
|
||||||
*/
|
*/
|
||||||
data class BakingOverride(
|
data class BakingOverride(
|
||||||
val modelLocation: ResourceLocation,
|
val modelLocation: Identifier,
|
||||||
val modelIdentifier: ModelResourceLocation
|
val modelIdentifier: ModelIdentifier
|
||||||
) {
|
) {
|
||||||
fun getModel(): BakedModel {
|
fun getModel(): BakedModel {
|
||||||
return Minecraft.getInstance().modelManager.getModel(modelIdentifier)
|
return MinecraftClient.getInstance().bakedModelManager.getModel(modelIdentifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
package com.cobblemon.mod.common
|
package com.cobblemon.mod.common
|
||||||
|
|
||||||
import com.cobblemon.mod.common.CobblemonBuildDetails.smallCommitHash
|
import com.cobblemon.mod.common.CobblemonBuildDetails.smallCommitHash
|
||||||
|
import com.cobblemon.mod.common.advancement.CobblemonCriteria
|
||||||
|
import com.cobblemon.mod.common.advancement.criterion.EvolvePokemonContext
|
||||||
import com.cobblemon.mod.common.api.Priority
|
import com.cobblemon.mod.common.api.Priority
|
||||||
import com.cobblemon.mod.common.api.SeasonResolver
|
import com.cobblemon.mod.common.api.SeasonResolver
|
||||||
import com.cobblemon.mod.common.api.data.DataProvider
|
import com.cobblemon.mod.common.api.data.DataProvider
|
||||||
@@ -16,8 +18,16 @@ import com.cobblemon.mod.common.api.drop.CommandDropEntry
|
|||||||
import com.cobblemon.mod.common.api.drop.DropEntry
|
import com.cobblemon.mod.common.api.drop.DropEntry
|
||||||
import com.cobblemon.mod.common.api.drop.ItemDropEntry
|
import com.cobblemon.mod.common.api.drop.ItemDropEntry
|
||||||
import com.cobblemon.mod.common.api.events.CobblemonEvents
|
import com.cobblemon.mod.common.api.events.CobblemonEvents
|
||||||
|
import com.cobblemon.mod.common.api.events.CobblemonEvents.BATTLE_VICTORY
|
||||||
import com.cobblemon.mod.common.api.events.CobblemonEvents.DATA_SYNCHRONIZED
|
import com.cobblemon.mod.common.api.events.CobblemonEvents.DATA_SYNCHRONIZED
|
||||||
import com.cobblemon.mod.common.api.interaction.RequestManager
|
import com.cobblemon.mod.common.api.events.CobblemonEvents.EVOLUTION_COMPLETE
|
||||||
|
import com.cobblemon.mod.common.api.events.CobblemonEvents.LEVEL_UP_EVENT
|
||||||
|
import com.cobblemon.mod.common.api.events.CobblemonEvents.POKEMON_CAPTURED
|
||||||
|
import com.cobblemon.mod.common.api.events.CobblemonEvents.TRADE_COMPLETED
|
||||||
|
import com.cobblemon.mod.common.api.net.serializers.IdentifierDataSerializer
|
||||||
|
import com.cobblemon.mod.common.api.net.serializers.PoseTypeDataSerializer
|
||||||
|
import com.cobblemon.mod.common.api.net.serializers.StringSetDataSerializer
|
||||||
|
import com.cobblemon.mod.common.api.net.serializers.Vec3DataSerializer
|
||||||
import com.cobblemon.mod.common.api.permission.PermissionValidator
|
import com.cobblemon.mod.common.api.permission.PermissionValidator
|
||||||
import com.cobblemon.mod.common.api.pokeball.catching.calculators.CaptureCalculator
|
import com.cobblemon.mod.common.api.pokeball.catching.calculators.CaptureCalculator
|
||||||
import com.cobblemon.mod.common.api.pokeball.catching.calculators.CaptureCalculators
|
import com.cobblemon.mod.common.api.pokeball.catching.calculators.CaptureCalculators
|
||||||
@@ -52,13 +62,9 @@ import com.cobblemon.mod.common.api.storage.factory.FileBackedPokemonStoreFactor
|
|||||||
import com.cobblemon.mod.common.api.storage.molang.NbtMoLangDataStoreFactory
|
import com.cobblemon.mod.common.api.storage.molang.NbtMoLangDataStoreFactory
|
||||||
import com.cobblemon.mod.common.api.storage.pc.PCStore
|
import com.cobblemon.mod.common.api.storage.pc.PCStore
|
||||||
import com.cobblemon.mod.common.api.storage.pc.link.PCLinkManager
|
import com.cobblemon.mod.common.api.storage.pc.link.PCLinkManager
|
||||||
import com.cobblemon.mod.common.api.storage.player.PlayerInstancedDataStoreManager
|
import com.cobblemon.mod.common.api.storage.player.PlayerDataStoreManager
|
||||||
import com.cobblemon.mod.common.api.storage.player.PlayerInstancedDataStoreTypes
|
import com.cobblemon.mod.common.api.storage.player.factory.JsonPlayerDataStoreFactory
|
||||||
import com.cobblemon.mod.common.api.storage.player.adapter.DexDataMongoBackend
|
import com.cobblemon.mod.common.api.storage.player.factory.MongoPlayerDataStoreFactory
|
||||||
import com.cobblemon.mod.common.api.storage.player.adapter.DexDataNbtBackend
|
|
||||||
import com.cobblemon.mod.common.api.storage.player.adapter.PlayerDataJsonBackend
|
|
||||||
import com.cobblemon.mod.common.api.storage.player.adapter.PlayerDataMongoBackend
|
|
||||||
import com.cobblemon.mod.common.api.storage.player.factory.CachedPlayerDataStoreFactory
|
|
||||||
import com.cobblemon.mod.common.api.tags.CobblemonEntityTypeTags
|
import com.cobblemon.mod.common.api.tags.CobblemonEntityTypeTags
|
||||||
import com.cobblemon.mod.common.api.tags.CobblemonItemTags
|
import com.cobblemon.mod.common.api.tags.CobblemonItemTags
|
||||||
import com.cobblemon.mod.common.battles.BagItems
|
import com.cobblemon.mod.common.battles.BagItems
|
||||||
@@ -68,17 +74,21 @@ import com.cobblemon.mod.common.battles.BattleSide
|
|||||||
import com.cobblemon.mod.common.battles.ShowdownThread
|
import com.cobblemon.mod.common.battles.ShowdownThread
|
||||||
import com.cobblemon.mod.common.battles.actor.PokemonBattleActor
|
import com.cobblemon.mod.common.battles.actor.PokemonBattleActor
|
||||||
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
|
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
|
||||||
import com.cobblemon.mod.common.client.CobblemonPack
|
import com.cobblemon.mod.common.command.argument.DialogueArgumentType
|
||||||
import com.cobblemon.mod.common.command.argument.*
|
import com.cobblemon.mod.common.command.argument.MoveArgumentType
|
||||||
|
import com.cobblemon.mod.common.command.argument.PartySlotArgumentType
|
||||||
|
import com.cobblemon.mod.common.command.argument.PokemonArgumentType
|
||||||
|
import com.cobblemon.mod.common.command.argument.PokemonPropertiesArgumentType
|
||||||
|
import com.cobblemon.mod.common.command.argument.PokemonStoreArgumentType
|
||||||
|
import com.cobblemon.mod.common.command.argument.SpawnBucketArgumentType
|
||||||
import com.cobblemon.mod.common.config.CobblemonConfig
|
import com.cobblemon.mod.common.config.CobblemonConfig
|
||||||
import com.cobblemon.mod.common.config.LastChangedVersion
|
import com.cobblemon.mod.common.config.LastChangedVersion
|
||||||
import com.cobblemon.mod.common.config.constraint.IntConstraint
|
import com.cobblemon.mod.common.config.constraint.IntConstraint
|
||||||
import com.cobblemon.mod.common.config.starter.StarterConfig
|
import com.cobblemon.mod.common.config.starter.StarterConfig
|
||||||
import com.cobblemon.mod.common.data.CobblemonDataProvider
|
import com.cobblemon.mod.common.data.CobblemonDataProvider
|
||||||
import com.cobblemon.mod.common.events.AdvancementHandler
|
import com.cobblemon.mod.common.events.AdvancementHandler
|
||||||
import com.cobblemon.mod.common.events.FlowHandler
|
|
||||||
import com.cobblemon.mod.common.events.PokedexHandler
|
|
||||||
import com.cobblemon.mod.common.events.ServerTickHandler
|
import com.cobblemon.mod.common.events.ServerTickHandler
|
||||||
|
import com.cobblemon.mod.common.item.PokeBallItem
|
||||||
import com.cobblemon.mod.common.net.messages.client.settings.ServerSettingsPacket
|
import com.cobblemon.mod.common.net.messages.client.settings.ServerSettingsPacket
|
||||||
import com.cobblemon.mod.common.permission.LaxPermissionValidator
|
import com.cobblemon.mod.common.permission.LaxPermissionValidator
|
||||||
import com.cobblemon.mod.common.platform.events.PlatformEvents
|
import com.cobblemon.mod.common.platform.events.PlatformEvents
|
||||||
@@ -88,21 +98,19 @@ import com.cobblemon.mod.common.pokemon.aspects.SHINY_ASPECT
|
|||||||
import com.cobblemon.mod.common.pokemon.evolution.variants.BlockClickEvolution
|
import com.cobblemon.mod.common.pokemon.evolution.variants.BlockClickEvolution
|
||||||
import com.cobblemon.mod.common.pokemon.feature.TagSeasonResolver
|
import com.cobblemon.mod.common.pokemon.feature.TagSeasonResolver
|
||||||
import com.cobblemon.mod.common.pokemon.helditem.CobblemonHeldItemManager
|
import com.cobblemon.mod.common.pokemon.helditem.CobblemonHeldItemManager
|
||||||
import com.cobblemon.mod.common.pokemon.properties.AspectPropertyType
|
|
||||||
import com.cobblemon.mod.common.pokemon.properties.BattleCloneProperty
|
|
||||||
import com.cobblemon.mod.common.pokemon.properties.FreezeFrameProperty
|
|
||||||
import com.cobblemon.mod.common.pokemon.properties.HiddenAbilityPropertyType
|
import com.cobblemon.mod.common.pokemon.properties.HiddenAbilityPropertyType
|
||||||
import com.cobblemon.mod.common.pokemon.properties.NoAIProperty
|
|
||||||
import com.cobblemon.mod.common.pokemon.properties.UnaspectPropertyType
|
|
||||||
import com.cobblemon.mod.common.pokemon.properties.UncatchableProperty
|
import com.cobblemon.mod.common.pokemon.properties.UncatchableProperty
|
||||||
import com.cobblemon.mod.common.pokemon.properties.tags.PokemonFlagProperty
|
import com.cobblemon.mod.common.pokemon.properties.tags.PokemonFlagProperty
|
||||||
import com.cobblemon.mod.common.pokemon.stat.CobblemonStatProvider
|
import com.cobblemon.mod.common.pokemon.stat.CobblemonStatProvider
|
||||||
|
import com.cobblemon.mod.common.sherds.CobblemonSherds
|
||||||
import com.cobblemon.mod.common.starter.CobblemonStarterHandler
|
import com.cobblemon.mod.common.starter.CobblemonStarterHandler
|
||||||
|
import com.cobblemon.mod.common.trade.TradeManager
|
||||||
import com.cobblemon.mod.common.util.DataKeys
|
import com.cobblemon.mod.common.util.DataKeys
|
||||||
import com.cobblemon.mod.common.util.cobblemonResource
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
import com.cobblemon.mod.common.util.ifDedicatedServer
|
import com.cobblemon.mod.common.util.ifDedicatedServer
|
||||||
import com.cobblemon.mod.common.util.isLaterVersion
|
import com.cobblemon.mod.common.util.isLaterVersion
|
||||||
import com.cobblemon.mod.common.util.party
|
import com.cobblemon.mod.common.util.party
|
||||||
|
import com.cobblemon.mod.common.util.removeAmountIf
|
||||||
import com.cobblemon.mod.common.util.server
|
import com.cobblemon.mod.common.util.server
|
||||||
import com.cobblemon.mod.common.world.feature.CobblemonPlacedFeatures
|
import com.cobblemon.mod.common.world.feature.CobblemonPlacedFeatures
|
||||||
import com.cobblemon.mod.common.world.feature.ore.CobblemonOrePlacedFeatures
|
import com.cobblemon.mod.common.world.feature.ore.CobblemonOrePlacedFeatures
|
||||||
@@ -111,31 +119,31 @@ import com.mongodb.ConnectionString
|
|||||||
import com.mongodb.MongoClientSettings
|
import com.mongodb.MongoClientSettings
|
||||||
import com.mongodb.client.MongoClient
|
import com.mongodb.client.MongoClient
|
||||||
import com.mongodb.client.MongoClients
|
import com.mongodb.client.MongoClients
|
||||||
|
import net.minecraft.client.MinecraftClient
|
||||||
|
import net.minecraft.command.argument.serialize.ConstantArgumentSerializer
|
||||||
|
import net.minecraft.entity.data.TrackedDataHandlerRegistry
|
||||||
|
import net.minecraft.item.Items
|
||||||
|
import net.minecraft.item.NameTagItem
|
||||||
|
import net.minecraft.registry.RegistryKey
|
||||||
|
import net.minecraft.util.WorldSavePath
|
||||||
|
import net.minecraft.world.World
|
||||||
|
import org.apache.logging.log4j.LogManager
|
||||||
|
import org.apache.logging.log4j.Logger
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileReader
|
import java.io.FileReader
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
import java.io.PrintWriter
|
import java.io.PrintWriter
|
||||||
import java.util.UUID
|
import java.util.*
|
||||||
import kotlin.math.roundToInt
|
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
import kotlin.reflect.full.memberProperties
|
import kotlin.reflect.full.memberProperties
|
||||||
import kotlin.reflect.jvm.isAccessible
|
import kotlin.reflect.jvm.isAccessible
|
||||||
import kotlin.reflect.jvm.javaField
|
import kotlin.reflect.jvm.javaField
|
||||||
import net.minecraft.client.Minecraft
|
import kotlin.math.roundToInt
|
||||||
import net.minecraft.commands.synchronization.SingletonArgumentInfo
|
|
||||||
import net.minecraft.resources.ResourceKey
|
|
||||||
import net.minecraft.server.packs.PackType
|
|
||||||
import net.minecraft.world.item.NameTagItem
|
|
||||||
import net.minecraft.world.level.Level
|
|
||||||
import net.minecraft.world.level.storage.LevelResource
|
|
||||||
import org.apache.logging.log4j.LogManager
|
|
||||||
import org.apache.logging.log4j.Logger
|
|
||||||
|
|
||||||
object Cobblemon {
|
object Cobblemon {
|
||||||
const val MODID = CobblemonBuildDetails.MOD_ID
|
const val MODID = "cobblemon"
|
||||||
const val VERSION = CobblemonBuildDetails.VERSION
|
const val VERSION = "1.4.0"
|
||||||
const val CONFIG_PATH = "config/$MODID/main.json"
|
const val CONFIG_PATH = "config/$MODID/main.json"
|
||||||
@JvmField
|
|
||||||
val LOGGER: Logger = LogManager.getLogger()
|
val LOGGER: Logger = LogManager.getLogger()
|
||||||
|
|
||||||
lateinit var implementation: CobblemonImplementation
|
lateinit var implementation: CobblemonImplementation
|
||||||
@@ -157,46 +165,32 @@ object Cobblemon {
|
|||||||
val battleRegistry = BattleRegistry
|
val battleRegistry = BattleRegistry
|
||||||
var storage = PokemonStoreManager()
|
var storage = PokemonStoreManager()
|
||||||
var molangData = NbtMoLangDataStoreFactory
|
var molangData = NbtMoLangDataStoreFactory
|
||||||
lateinit var playerDataManager: PlayerInstancedDataStoreManager
|
lateinit var playerData: PlayerDataStoreManager
|
||||||
lateinit var starterConfig: StarterConfig
|
lateinit var starterConfig: StarterConfig
|
||||||
val dataProvider: DataProvider = CobblemonDataProvider
|
val dataProvider: DataProvider = CobblemonDataProvider
|
||||||
var permissionValidator: PermissionValidator by Delegates.observable(LaxPermissionValidator().also { it.initialize() }) { _, _, newValue -> newValue.initialize() }
|
var permissionValidator: PermissionValidator by Delegates.observable(LaxPermissionValidator().also { it.initialize() }) { _, _, newValue -> newValue.initialize() }
|
||||||
var statProvider: StatProvider = CobblemonStatProvider
|
var statProvider: StatProvider = CobblemonStatProvider
|
||||||
var seasonResolver: SeasonResolver = TagSeasonResolver
|
var seasonResolver: SeasonResolver = TagSeasonResolver
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
val builtinPacks = listOf<CobblemonPack>(
|
|
||||||
CobblemonPack(id = "adorncompatibility", name = "Adorn Compatibility", packType = PackType.CLIENT_RESOURCES, activationBehaviour = ResourcePackActivationBehaviour.ALWAYS_ENABLED, neededMods = setOf("adorn")),
|
|
||||||
CobblemonPack(id = "gyaradosjump", name = "Gyarados Jump Patterns", packType = PackType.CLIENT_RESOURCES, activationBehaviour = ResourcePackActivationBehaviour.DEFAULT_ENABLED),
|
|
||||||
CobblemonPack(id = "regionbiasforms", name = "Region Bias Forms", packType = PackType.CLIENT_RESOURCES, activationBehaviour = ResourcePackActivationBehaviour.DEFAULT_ENABLED),
|
|
||||||
CobblemonPack(id = "uniqueshinyforms", name = "Shinies for Magikarp Jump", packType = PackType.CLIENT_RESOURCES, activationBehaviour = ResourcePackActivationBehaviour.NORMAL),
|
|
||||||
|
|
||||||
CobblemonPack(id = "repurposedstructurescobblemon", name = "Repurposed Structures Cobblemon", packType = PackType.SERVER_DATA, activationBehaviour = ResourcePackActivationBehaviour.DEFAULT_ENABLED, neededMods = setOf("repurposed_structures")),
|
|
||||||
)
|
|
||||||
|
|
||||||
fun preInitialize(implementation: CobblemonImplementation) {
|
fun preInitialize(implementation: CobblemonImplementation) {
|
||||||
this.implementation = implementation
|
this.implementation = implementation
|
||||||
|
|
||||||
this.LOGGER.info("Launching Cobblemon ${CobblemonBuildDetails.VERSION}${if(CobblemonBuildDetails.SNAPSHOT) "-SNAPSHOT" else ""} ")
|
this.LOGGER.info("Launching Cobblemon ${CobblemonBuildDetails.VERSION}${if(CobblemonBuildDetails.SNAPSHOT) "-SNAPSHOT" else ""} ")
|
||||||
if (CobblemonBuildDetails.SNAPSHOT) {
|
if(CobblemonBuildDetails.SNAPSHOT) {
|
||||||
this.LOGGER.info(" - Git Commit: ${smallCommitHash()} (https://gitlab.com/cable-mc/cobblemon/-/commit/${CobblemonBuildDetails.GIT_COMMIT})")
|
this.LOGGER.info(" - Git Commit: ${smallCommitHash()} (https://gitlab.com/cable-mc/cobblemon/-/commit/${CobblemonBuildDetails.GIT_COMMIT})")
|
||||||
this.LOGGER.info(" - Branch: ${CobblemonBuildDetails.BRANCH}")
|
this.LOGGER.info(" - Branch: ${CobblemonBuildDetails.BRANCH}")
|
||||||
|
this.LOGGER.info(" - Timestamp: ${CobblemonBuildDetails.TIMESTAMP}")
|
||||||
}
|
}
|
||||||
|
|
||||||
implementation.registerPermissionValidator()
|
implementation.registerPermissionValidator()
|
||||||
implementation.registerSoundEvents()
|
implementation.registerSoundEvents()
|
||||||
implementation.registerDataComponents()
|
|
||||||
implementation.registerBlocks()
|
implementation.registerBlocks()
|
||||||
implementation.registerItems()
|
implementation.registerItems()
|
||||||
implementation.registerEntityTypes()
|
implementation.registerEntityTypes()
|
||||||
implementation.registerEntityAttributes()
|
implementation.registerEntityAttributes()
|
||||||
implementation.registerBlockEntityTypes()
|
implementation.registerBlockEntityTypes()
|
||||||
implementation.registerVillagers()
|
|
||||||
implementation.registerWorldGenFeatures()
|
implementation.registerWorldGenFeatures()
|
||||||
implementation.registerParticles()
|
implementation.registerParticles()
|
||||||
implementation.registerEntityDataSerializers()
|
|
||||||
implementation.registerCriteria()
|
|
||||||
implementation.registerEntitySubPredicates()
|
|
||||||
|
|
||||||
DropEntry.register("command", CommandDropEntry::class.java)
|
DropEntry.register("command", CommandDropEntry::class.java)
|
||||||
DropEntry.register("item", ItemDropEntry::class.java, isDefault = true)
|
DropEntry.register("item", ItemDropEntry::class.java, isDefault = true)
|
||||||
@@ -210,22 +204,23 @@ object Cobblemon {
|
|||||||
CobblemonPlacedFeatures.register()
|
CobblemonPlacedFeatures.register()
|
||||||
this.registerArgumentTypes()
|
this.registerArgumentTypes()
|
||||||
|
|
||||||
|
CobblemonCriteria // Init the fields and register the criteria
|
||||||
CobblemonGameRules // Init fields and register
|
CobblemonGameRules // Init fields and register
|
||||||
|
|
||||||
ShoulderEffectRegistry.register()
|
ShoulderEffectRegistry.register()
|
||||||
|
|
||||||
DATA_SYNCHRONIZED.subscribe {
|
DATA_SYNCHRONIZED.subscribe {
|
||||||
storage.onPlayerDataSync(it)
|
storage.onPlayerDataSync(it)
|
||||||
playerDataManager.syncAllToPlayer(it)
|
playerData.get(it).sendToPlayer(it)
|
||||||
starterHandler.handleJoin(it)
|
starterHandler.handleJoin(it)
|
||||||
ServerSettingsPacket(this.config.preventCompletePartyDeposit, this.config.displayEntityLevelLabel, this.config.displayEntityNameLabel, this.config.maxPokemonLevel).sendToPlayer(it)
|
ServerSettingsPacket(this.config.preventCompletePartyDeposit, this.config.displayEntityLevelLabel).sendToPlayer(it)
|
||||||
}
|
}
|
||||||
PlatformEvents.SERVER_PLAYER_LOGOUT.subscribe {
|
PlatformEvents.SERVER_PLAYER_LOGOUT.subscribe {
|
||||||
PCLinkManager.removeLink(it.player.uuid)
|
PCLinkManager.removeLink(it.player.uuid)
|
||||||
BattleRegistry.onPlayerDisconnect(it.player)
|
BattleRegistry.getBattleByParticipatingPlayer(it.player)?.stop()
|
||||||
storage.onPlayerDisconnect(it.player)
|
storage.onPlayerDisconnect(it.player)
|
||||||
playerDataManager.onPlayerDisconnect(it.player)
|
playerData.onPlayerDisconnect(it.player)
|
||||||
RequestManager.onLogoff(it.player)
|
TradeManager.onLogoff(it.player)
|
||||||
}
|
}
|
||||||
PlatformEvents.PLAYER_DEATH.subscribe {
|
PlatformEvents.PLAYER_DEATH.subscribe {
|
||||||
PCLinkManager.removeLink(it.player.uuid)
|
PCLinkManager.removeLink(it.player.uuid)
|
||||||
@@ -233,39 +228,45 @@ object Cobblemon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlatformEvents.RIGHT_CLICK_ENTITY.subscribe { event ->
|
PlatformEvents.RIGHT_CLICK_ENTITY.subscribe { event ->
|
||||||
if (event.player.getItemInHand(event.hand).item is NameTagItem && event.entity.type.`is`(CobblemonEntityTypeTags.CANNOT_HAVE_NAME_TAG)) {
|
if (event.player.getStackInHand(event.hand).item is NameTagItem && event.entity.type.isIn(CobblemonEntityTypeTags.CANNOT_HAVE_NAME_TAG)) {
|
||||||
event.cancel()
|
event.cancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlatformEvents.RIGHT_CLICK_BLOCK.subscribe { event ->
|
PlatformEvents.RIGHT_CLICK_BLOCK.subscribe { event ->
|
||||||
val player = event.player
|
val player = event.player
|
||||||
val block = player.level().getBlockState(event.pos).block
|
val block = player.world.getBlockState(event.pos).block
|
||||||
player.party().forEach { pokemon ->
|
player.party().forEach { pokemon ->
|
||||||
pokemon.lockedEvolutions
|
pokemon.evolutions
|
||||||
.filterIsInstance<BlockClickEvolution>()
|
.filterIsInstance<BlockClickEvolution>()
|
||||||
.forEach { evolution ->
|
.forEach { evolution ->
|
||||||
evolution.attemptEvolution(pokemon, BlockClickEvolution.BlockInteractionContext(block, player.level()))
|
evolution.attemptEvolution(pokemon, BlockClickEvolution.BlockInteractionContext(block, player.world))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register the grow_tumblestone advancement
|
||||||
|
PlatformEvents.RIGHT_CLICK_BLOCK.subscribe { AdvancementHandler.onTumbleStonePlaced(it) }
|
||||||
|
|
||||||
PlatformEvents.CHANGE_DIMENSION.subscribe {
|
PlatformEvents.CHANGE_DIMENSION.subscribe {
|
||||||
it.player.party().forEach { pokemon -> pokemon.entity?.recallWithAnimation() }
|
it.player.party().forEach { pokemon -> pokemon.entity?.recallWithAnimation() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TrackedDataHandlerRegistry.register(Vec3DataSerializer)
|
||||||
|
TrackedDataHandlerRegistry.register(StringSetDataSerializer)
|
||||||
|
TrackedDataHandlerRegistry.register(PoseTypeDataSerializer)
|
||||||
|
TrackedDataHandlerRegistry.register(IdentifierDataSerializer)
|
||||||
|
|
||||||
// Lowest priority because this applies after luxury ball bonus as of gen 4
|
// Lowest priority because this applies after luxury ball bonus as of gen 4
|
||||||
CobblemonEvents.FRIENDSHIP_UPDATED.subscribe(Priority.LOWEST) { event ->
|
CobblemonEvents.FRIENDSHIP_UPDATED.subscribe(Priority.LOWEST) { event ->
|
||||||
var increment = (event.newFriendship - event.pokemon.friendship).toFloat()
|
var increment = (event.newFriendship - event.pokemon.friendship).toFloat()
|
||||||
// Our Luxury ball spec is diff from official, but we will still assume these stack
|
// Our Luxury ball spec is diff from official, but we will still assume these stack
|
||||||
if (event.pokemon.heldItemNoCopy().`is`(CobblemonItemTags.IS_FRIENDSHIP_BOOSTER)) {
|
if (event.pokemon.heldItemNoCopy().isIn(CobblemonItemTags.IS_FRIENDSHIP_BOOSTER)) {
|
||||||
increment += increment * 0.5F
|
increment += increment * 0.5F
|
||||||
}
|
}
|
||||||
event.newFriendship = event.pokemon.friendship + increment.roundToInt()
|
event.newFriendship = event.pokemon.friendship + increment.roundToInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
HeldItemProvider.register(CobblemonHeldItemManager, Priority.LOWEST)
|
HeldItemProvider.register(CobblemonHeldItemManager, Priority.LOWEST)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun initialize() {
|
fun initialize() {
|
||||||
@@ -289,17 +290,8 @@ object Cobblemon {
|
|||||||
FlagSpeciesFeatureProvider(keys = listOf(DataKeys.HAS_BEEN_SHEARED), default = false))
|
FlagSpeciesFeatureProvider(keys = listOf(DataKeys.HAS_BEEN_SHEARED), default = false))
|
||||||
|
|
||||||
CustomPokemonProperty.register(UncatchableProperty)
|
CustomPokemonProperty.register(UncatchableProperty)
|
||||||
CustomPokemonProperty.register(BattleCloneProperty)
|
|
||||||
CustomPokemonProperty.register(PokemonFlagProperty)
|
CustomPokemonProperty.register(PokemonFlagProperty)
|
||||||
CustomPokemonProperty.register(HiddenAbilityPropertyType)
|
CustomPokemonProperty.register(HiddenAbilityPropertyType)
|
||||||
CustomPokemonProperty.register(AspectPropertyType)
|
|
||||||
CustomPokemonProperty.register(UnaspectPropertyType)
|
|
||||||
CustomPokemonProperty.register(FreezeFrameProperty)
|
|
||||||
CustomPokemonProperty.register(NoAIProperty)
|
|
||||||
|
|
||||||
CobblemonEvents.POKEMON_PROPERTY_INITIALISED.emit(Unit)
|
|
||||||
|
|
||||||
FlowHandler.setup()
|
|
||||||
|
|
||||||
ifDedicatedServer {
|
ifDedicatedServer {
|
||||||
isDedicatedServer = true
|
isDedicatedServer = true
|
||||||
@@ -314,21 +306,16 @@ object Cobblemon {
|
|||||||
}
|
}
|
||||||
PlatformEvents.SERVER_STARTING.subscribe { event ->
|
PlatformEvents.SERVER_STARTING.subscribe { event ->
|
||||||
val server = event.server
|
val server = event.server
|
||||||
playerDataManager = PlayerInstancedDataStoreManager().also { it.setup(server) }
|
playerData = PlayerDataStoreManager().also { it.setup(server) }
|
||||||
|
|
||||||
val mongoClient: MongoClient?
|
val mongoClient: MongoClient?
|
||||||
|
|
||||||
val pokemonStoreRoot = server.getWorldPath(LevelResource.ROOT).resolve("pokemon").toFile()
|
val pokemonStoreRoot = server.getSavePath(WorldSavePath.ROOT).resolve("pokemon").toFile()
|
||||||
val storeAdapter = when (config.storageFormat) {
|
val storeAdapter = when (config.storageFormat) {
|
||||||
"nbt", "json" -> {
|
"nbt", "json" -> {
|
||||||
val generalJsonFactory = CachedPlayerDataStoreFactory(PlayerDataJsonBackend())
|
val jsonFactory = JsonPlayerDataStoreFactory()
|
||||||
generalJsonFactory.setup(server)
|
jsonFactory.setup(server)
|
||||||
|
playerData.setFactory(jsonFactory)
|
||||||
val pokedexNbtFactory = CachedPlayerDataStoreFactory(DexDataNbtBackend())
|
|
||||||
pokedexNbtFactory.setup(server)
|
|
||||||
|
|
||||||
playerDataManager.setFactory(generalJsonFactory, PlayerInstancedDataStoreTypes.GENERAL)
|
|
||||||
playerDataManager.setFactory(pokedexNbtFactory, PlayerInstancedDataStoreTypes.POKEDEX)
|
|
||||||
|
|
||||||
if (config.storageFormat == "nbt") {
|
if (config.storageFormat == "nbt") {
|
||||||
NBTStoreAdapter(pokemonStoreRoot.absolutePath, useNestedFolders = true, folderPerClass = true)
|
NBTStoreAdapter(pokemonStoreRoot.absolutePath, useNestedFolders = true, folderPerClass = true)
|
||||||
@@ -349,26 +336,18 @@ object Cobblemon {
|
|||||||
.applyConnectionString(ConnectionString(config.mongoDBConnectionString))
|
.applyConnectionString(ConnectionString(config.mongoDBConnectionString))
|
||||||
.build()
|
.build()
|
||||||
mongoClient = MongoClients.create(mongoClientSettings)
|
mongoClient = MongoClients.create(mongoClientSettings)
|
||||||
val generalMongoFactory = CachedPlayerDataStoreFactory(PlayerDataMongoBackend(mongoClient, config.mongoDBDatabaseName, "PlayerDataCollection"))
|
val mongoFactory = MongoPlayerDataStoreFactory(mongoClient, config.mongoDBDatabaseName)
|
||||||
generalMongoFactory.setup(server)
|
playerData.setFactory(mongoFactory)
|
||||||
|
|
||||||
val pokedexMongoFactory = CachedPlayerDataStoreFactory(DexDataMongoBackend(mongoClient, config.mongoDBDatabaseName, "PokeDexCollection"))
|
|
||||||
pokedexMongoFactory.setup(server)
|
|
||||||
|
|
||||||
playerDataManager.setFactory(generalMongoFactory, PlayerInstancedDataStoreTypes.GENERAL)
|
|
||||||
playerDataManager.setFactory(pokedexMongoFactory, PlayerInstancedDataStoreTypes.POKEDEX)
|
|
||||||
MongoDBStoreAdapter(mongoClient, config.mongoDBDatabaseName)
|
MongoDBStoreAdapter(mongoClient, config.mongoDBDatabaseName)
|
||||||
} catch (e: ClassNotFoundException) {
|
} catch (e: ClassNotFoundException) {
|
||||||
LOGGER.error("MongoDB driver not found.")
|
LOGGER.error("MongoDB driver not found.")
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
else -> throw IllegalArgumentException("Unsupported storageFormat: ${config.storageFormat}")
|
else -> throw IllegalArgumentException("Unsupported storageFormat: ${config.storageFormat}")
|
||||||
}
|
}
|
||||||
.with(ReforgedConversion(server.getWorldPath(LevelResource.ROOT))) as FileStoreAdapter<*>
|
.with(ReforgedConversion(server.getSavePath(WorldSavePath.ROOT))) as FileStoreAdapter<*>
|
||||||
|
|
||||||
storage.registerFactory(
|
storage.registerFactory(
|
||||||
priority = Priority.LOWEST,
|
priority = Priority.LOWEST,
|
||||||
@@ -381,14 +360,52 @@ object Cobblemon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlatformEvents.SERVER_STOPPED.subscribe {
|
PlatformEvents.SERVER_STOPPED.subscribe {
|
||||||
storage.unregisterAll(it.server.registryAccess())
|
storage.unregisterAll()
|
||||||
playerDataManager.saveAllStores()
|
playerData.saveAll()
|
||||||
}
|
}
|
||||||
PlatformEvents.SERVER_STARTED.subscribe {
|
PlatformEvents.SERVER_STARTED.subscribe {
|
||||||
bestSpawner.onServerStarted()
|
bestSpawner.onServerStarted()
|
||||||
battleRegistry.onServerStarted()
|
battleRegistry.onServerStarted()
|
||||||
}
|
}
|
||||||
PlatformEvents.SERVER_TICK_POST.subscribe { ServerTickHandler.onTick(it.server) }
|
PlatformEvents.SERVER_TICK_POST.subscribe { ServerTickHandler.onTick(it.server) }
|
||||||
|
POKEMON_CAPTURED.subscribe { AdvancementHandler.onCapture(it) }
|
||||||
|
// EGG_HATCH.subscribe { AdvancementHandler.onHatch(it) }
|
||||||
|
BATTLE_VICTORY.subscribe { AdvancementHandler.onWinBattle(it) }
|
||||||
|
EVOLUTION_COMPLETE.subscribe(Priority.LOWEST) { event ->
|
||||||
|
AdvancementHandler.onEvolve(event)
|
||||||
|
val pokemon = event.pokemon
|
||||||
|
val ninjaskIdentifier = cobblemonResource("ninjask")
|
||||||
|
// Ensure the config option is enabled and that the result was a ninjask and that shedinja exists
|
||||||
|
if (this.config.ninjaskCreatesShedinja && pokemon.species.resourceIdentifier == ninjaskIdentifier && PokemonSpecies.getByIdentifier(Pokemon.SHEDINJA) != null) {
|
||||||
|
val player = pokemon.getOwnerPlayer() ?: return@subscribe
|
||||||
|
if (player.isCreative || player.inventory.containsAny { it.item is PokeBallItem }) {
|
||||||
|
var pokeball = Items.AIR
|
||||||
|
player.inventory.combinedInventory.forEach {
|
||||||
|
it.forEach {
|
||||||
|
itemStack -> if (itemStack.item is PokeBallItem && pokeball == Items.AIR) {
|
||||||
|
pokeball = itemStack.item as PokeBallItem
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!player.isCreative) {
|
||||||
|
player.inventory.removeAmountIf(1) { it.item is PokeBallItem }
|
||||||
|
}
|
||||||
|
if (pokeball == Items.AIR) {
|
||||||
|
pokeball = CobblemonItems.POKE_BALL
|
||||||
|
}
|
||||||
|
val properties = event.evolution.result.copy()
|
||||||
|
properties.species = Pokemon.SHEDINJA.toString()
|
||||||
|
val product = pokemon.clone()
|
||||||
|
product.removeHeldItem()
|
||||||
|
properties.apply(product)
|
||||||
|
product.caughtBall = (pokeball as PokeBallItem).pokeBall
|
||||||
|
pokemon.storeCoordinates.get()?.store?.add(product)
|
||||||
|
CobblemonCriteria.EVOLVE_POKEMON.trigger(player, EvolvePokemonContext(event.pokemon.preEvolution!!.species.resourceIdentifier, product.species.resourceIdentifier, playerData.get(player).advancementData.totalEvolvedCount))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LEVEL_UP_EVENT.subscribe { AdvancementHandler.onLevelUp(it) }
|
||||||
|
TRADE_COMPLETED.subscribe { AdvancementHandler.onTradeCompleted(it) }
|
||||||
|
|
||||||
BagItems.observable.subscribe {
|
BagItems.observable.subscribe {
|
||||||
LOGGER.info("Starting dummy Showdown battle to force it to pre-load data.")
|
LOGGER.info("Starting dummy Showdown battle to force it to pre-load data.")
|
||||||
@@ -396,32 +413,19 @@ object Cobblemon {
|
|||||||
BattleFormat.GEN_9_SINGLES,
|
BattleFormat.GEN_9_SINGLES,
|
||||||
BattleSide(PokemonBattleActor(UUID.randomUUID(), BattlePokemon(Pokemon().initialize()), -1F)),
|
BattleSide(PokemonBattleActor(UUID.randomUUID(), BattlePokemon(Pokemon().initialize()), -1F)),
|
||||||
BattleSide(PokemonBattleActor(UUID.randomUUID(), BattlePokemon(Pokemon().initialize()), -1F)),
|
BattleSide(PokemonBattleActor(UUID.randomUUID(), BattlePokemon(Pokemon().initialize()), -1F)),
|
||||||
false
|
true
|
||||||
).ifSuccessful {
|
).ifSuccessful { it.mute = true }
|
||||||
it.mute = true
|
|
||||||
}.ifErrored {
|
|
||||||
val errors = it.errors.joinToString("\n") { it.javaClass.name }
|
|
||||||
LOGGER.error("Failed to start dummy Showdown battle: $errors")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
registerEventHandlers()
|
CobblemonSherds.registerSherds()
|
||||||
|
|
||||||
CobblemonEvents.COBBLEMON_INITIALISED.emit(Unit)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun registerEventHandlers() {
|
fun getLevel(dimension: RegistryKey<World>): World? {
|
||||||
AdvancementHandler.registerListeners()
|
|
||||||
PokedexHandler.registerListeners()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getLevel(dimension: ResourceKey<Level>): Level? {
|
|
||||||
return if (isDedicatedServer) {
|
return if (isDedicatedServer) {
|
||||||
server()?.getLevel(dimension)
|
server()?.getWorld(dimension)
|
||||||
} else {
|
} else {
|
||||||
val mc = Minecraft.getInstance()
|
val mc = MinecraftClient.getInstance()
|
||||||
return mc.singleplayerServer?.getLevel(dimension) ?: mc.level
|
return mc.server?.getWorld(dimension) ?: mc.world
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,16 +515,13 @@ object Cobblemon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun registerArgumentTypes() {
|
private fun registerArgumentTypes() {
|
||||||
this.implementation.registerCommandArgument(cobblemonResource("pokemon"), SpeciesArgumentType::class, SingletonArgumentInfo.contextFree(SpeciesArgumentType::species))
|
this.implementation.registerCommandArgument(cobblemonResource("pokemon"), PokemonArgumentType::class, ConstantArgumentSerializer.of(PokemonArgumentType::pokemon))
|
||||||
this.implementation.registerCommandArgument(cobblemonResource("pokemon_properties"), PokemonPropertiesArgumentType::class, SingletonArgumentInfo.contextFree(PokemonPropertiesArgumentType::properties))
|
this.implementation.registerCommandArgument(cobblemonResource("pokemon_properties"), PokemonPropertiesArgumentType::class, ConstantArgumentSerializer.of(PokemonPropertiesArgumentType::properties))
|
||||||
this.implementation.registerCommandArgument(cobblemonResource("spawn_bucket"), SpawnBucketArgumentType::class, SingletonArgumentInfo.contextFree(SpawnBucketArgumentType::spawnBucket))
|
this.implementation.registerCommandArgument(cobblemonResource("spawn_bucket"), SpawnBucketArgumentType::class, ConstantArgumentSerializer.of(SpawnBucketArgumentType::spawnBucket))
|
||||||
this.implementation.registerCommandArgument(cobblemonResource("move"), MoveArgumentType::class, SingletonArgumentInfo.contextFree(MoveArgumentType::move))
|
this.implementation.registerCommandArgument(cobblemonResource("move"), MoveArgumentType::class, ConstantArgumentSerializer.of(MoveArgumentType::move))
|
||||||
this.implementation.registerCommandArgument(cobblemonResource("party_slot"), PartySlotArgumentType::class, SingletonArgumentInfo.contextFree(PartySlotArgumentType::partySlot))
|
this.implementation.registerCommandArgument(cobblemonResource("party_slot"), PartySlotArgumentType::class, ConstantArgumentSerializer.of(PartySlotArgumentType::partySlot))
|
||||||
this.implementation.registerCommandArgument(cobblemonResource("pokemon_store"), PokemonStoreArgumentType::class, SingletonArgumentInfo.contextFree(PokemonStoreArgumentType::pokemonStore))
|
this.implementation.registerCommandArgument(cobblemonResource("pokemon_store"), PokemonStoreArgumentType::class, ConstantArgumentSerializer.of(PokemonStoreArgumentType::pokemonStore))
|
||||||
this.implementation.registerCommandArgument(cobblemonResource("dialogue"), DialogueArgumentType::class, SingletonArgumentInfo.contextFree(DialogueArgumentType::dialogue))
|
this.implementation.registerCommandArgument(cobblemonResource("dialogue"), DialogueArgumentType::class, ConstantArgumentSerializer.of(DialogueArgumentType::dialogue))
|
||||||
this.implementation.registerCommandArgument(cobblemonResource("form"), FormArgumentType::class, SingletonArgumentInfo.contextFree(FormArgumentType::form))
|
|
||||||
this.implementation.registerCommandArgument(cobblemonResource("dex"), DexArgumentType::class, SingletonArgumentInfo.contextFree (DexArgumentType::dex))
|
|
||||||
this.implementation.registerCommandArgument(cobblemonResource("npc_class"), NPCClassArgumentType::class, SingletonArgumentInfo.contextFree(NPCClassArgumentType::npcClass))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,11 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common
|
package com.cobblemon.mod.common
|
||||||
|
|
||||||
import net.minecraft.world.entity.schedule.Activity
|
import net.minecraft.entity.ai.brain.Activity
|
||||||
|
|
||||||
object CobblemonActivities {
|
object CobblemonActivities {
|
||||||
val activities = mutableListOf<Activity>()
|
val activities = mutableListOf<Activity>()
|
||||||
val BATTLING = register(Activity("battling"))
|
val BATTLING_ACTIVITY = Activity("pokemon_battling")
|
||||||
val ACTION_EFFECT = register(Activity("action_effect"))
|
|
||||||
val NPC_CHATTING = register(Activity("npc_chatting"))
|
|
||||||
|
|
||||||
fun register(activity: Activity): Activity {
|
fun register(activity: Activity): Activity {
|
||||||
activities.add(activity)
|
activities.add(activity)
|
||||||
|
|||||||
@@ -19,38 +19,35 @@ import com.cobblemon.mod.common.block.multiblock.FossilMultiblockBuilder
|
|||||||
import com.cobblemon.mod.common.block.entity.*
|
import com.cobblemon.mod.common.block.entity.*
|
||||||
import com.cobblemon.mod.common.block.entity.DisplayCaseBlockEntity
|
import com.cobblemon.mod.common.block.entity.DisplayCaseBlockEntity
|
||||||
import com.cobblemon.mod.common.platform.PlatformRegistry
|
import com.cobblemon.mod.common.platform.PlatformRegistry
|
||||||
import net.minecraft.core.Registry
|
import net.minecraft.block.entity.BlockEntityType
|
||||||
import net.minecraft.core.registries.BuiltInRegistries
|
import net.minecraft.registry.Registries
|
||||||
import net.minecraft.core.registries.Registries
|
import net.minecraft.registry.Registry
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
import net.minecraft.registry.RegistryKey
|
||||||
import net.minecraft.resources.ResourceKey
|
import net.minecraft.registry.RegistryKeys
|
||||||
|
|
||||||
object CobblemonBlockEntities : PlatformRegistry<Registry<BlockEntityType<*>>, ResourceKey<Registry<BlockEntityType<*>>>, BlockEntityType<*>>() {
|
object CobblemonBlockEntities : PlatformRegistry<Registry<BlockEntityType<*>>, RegistryKey<Registry<BlockEntityType<*>>>, BlockEntityType<*>>() {
|
||||||
|
|
||||||
override val registry: Registry<BlockEntityType<*>> = BuiltInRegistries.BLOCK_ENTITY_TYPE
|
override val registry: Registry<BlockEntityType<*>> = Registries.BLOCK_ENTITY_TYPE
|
||||||
override val resourceKey: ResourceKey<Registry<BlockEntityType<*>>> = Registries.BLOCK_ENTITY_TYPE
|
override val registryKey: RegistryKey<Registry<BlockEntityType<*>>> = RegistryKeys.BLOCK_ENTITY_TYPE
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val HEALING_MACHINE: BlockEntityType<HealingMachineBlockEntity> = this.create("healing_machine", BlockEntityType.Builder.of(::HealingMachineBlockEntity, CobblemonBlocks.HEALING_MACHINE).build(null))
|
val HEALING_MACHINE: BlockEntityType<HealingMachineBlockEntity> = this.create("healing_machine", BlockEntityType.Builder.create(::HealingMachineBlockEntity, CobblemonBlocks.HEALING_MACHINE).build(null))
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val PC: BlockEntityType<PCBlockEntity> = this.create("pc", BlockEntityType.Builder.of(::PCBlockEntity, CobblemonBlocks.PC).build(null))
|
val PC: BlockEntityType<PCBlockEntity> = this.create("pc", BlockEntityType.Builder.create(::PCBlockEntity, CobblemonBlocks.PC).build(null))
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val LECTERN: BlockEntityType<LecternBlockEntity> = this.create("lectern", BlockEntityType.Builder.of(::LecternBlockEntity, CobblemonBlocks.LECTERN).build(null))
|
val BERRY = this.create("berry", BlockEntityType.Builder.create(::BerryBlockEntity, *CobblemonBlocks.berries().values.toTypedArray()).build(null))
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val BERRY = this.create("berry", BlockEntityType.Builder.of(::BerryBlockEntity, *CobblemonBlocks.berries().values.toTypedArray()).build(null))
|
val PASTURE: BlockEntityType<PokemonPastureBlockEntity> = this.create("pasture", BlockEntityType.Builder.create(::PokemonPastureBlockEntity, CobblemonBlocks.PASTURE).build(null))
|
||||||
|
@JvmField
|
||||||
|
val SIGN: BlockEntityType<CobblemonSignBlockEntity> = this.create("sign", BlockEntityType.Builder.create(::CobblemonSignBlockEntity, CobblemonBlocks.APRICORN_SIGN, CobblemonBlocks.APRICORN_WALL_SIGN).build(null))
|
||||||
|
@JvmField
|
||||||
|
val HANGING_SIGN: BlockEntityType<CobblemonHangingSignBlockEntity> = this.create("hanging_sign", BlockEntityType.Builder.create(::CobblemonHangingSignBlockEntity, CobblemonBlocks.APRICORN_HANGING_SIGN, CobblemonBlocks.APRICORN_WALL_HANGING_SIGN).build(null))
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val PASTURE: BlockEntityType<PokemonPastureBlockEntity> = this.create("pasture", BlockEntityType.Builder.of(::PokemonPastureBlockEntity, CobblemonBlocks.PASTURE).build(null))
|
val GILDED_CHEST: BlockEntityType<GildedChestBlockEntity> = this.create("chest", BlockEntityType.Builder.create(::GildedChestBlockEntity,
|
||||||
@JvmField
|
|
||||||
val SIGN: BlockEntityType<CobblemonSignBlockEntity> = this.create("sign", BlockEntityType.Builder.of(::CobblemonSignBlockEntity, CobblemonBlocks.APRICORN_SIGN, CobblemonBlocks.APRICORN_WALL_SIGN).build(null))
|
|
||||||
@JvmField
|
|
||||||
val HANGING_SIGN: BlockEntityType<CobblemonHangingSignBlockEntity> = this.create("hanging_sign", BlockEntityType.Builder.of(::CobblemonHangingSignBlockEntity, CobblemonBlocks.APRICORN_HANGING_SIGN, CobblemonBlocks.APRICORN_WALL_HANGING_SIGN).build(null))
|
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val GILDED_CHEST: BlockEntityType<GildedChestBlockEntity> = this.create("chest", BlockEntityType.Builder.of(::GildedChestBlockEntity,
|
|
||||||
CobblemonBlocks.GILDED_CHEST,
|
CobblemonBlocks.GILDED_CHEST,
|
||||||
CobblemonBlocks.BLUE_GILDED_CHEST,
|
CobblemonBlocks.BLUE_GILDED_CHEST,
|
||||||
CobblemonBlocks.YELLOW_GILDED_CHEST,
|
CobblemonBlocks.YELLOW_GILDED_CHEST,
|
||||||
@@ -63,27 +60,27 @@ object CobblemonBlockEntities : PlatformRegistry<Registry<BlockEntityType<*>>, R
|
|||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val FOSSIL_MULTIBLOCK: BlockEntityType<FossilMultiblockEntity> = this.create("fossil_multiblock",
|
val FOSSIL_MULTIBLOCK: BlockEntityType<FossilMultiblockEntity> = this.create("fossil_multiblock",
|
||||||
BlockEntityType.Builder.of({ pos, state -> FossilMultiblockEntity(pos, state, FossilMultiblockBuilder(pos)) },
|
BlockEntityType.Builder.create({ pos, state -> FossilMultiblockEntity(pos, state, FossilMultiblockBuilder(pos)) },
|
||||||
CobblemonBlocks.MONITOR
|
CobblemonBlocks.MONITOR
|
||||||
).build(null)
|
).build(null)
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val RESTORATION_TANK: BlockEntityType<RestorationTankBlockEntity> = this.create("restoration_tank",
|
val RESTORATION_TANK: BlockEntityType<RestorationTankBlockEntity> = this.create("restoration_tank",
|
||||||
BlockEntityType.Builder.of({ pos, state -> RestorationTankBlockEntity(pos, state, FossilMultiblockBuilder(pos)) },
|
BlockEntityType.Builder.create({ pos, state -> RestorationTankBlockEntity(pos, state, FossilMultiblockBuilder(pos)) },
|
||||||
CobblemonBlocks.RESTORATION_TANK
|
CobblemonBlocks.RESTORATION_TANK
|
||||||
).build(null)
|
).build(null)
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val FOSSIL_ANALYZER: BlockEntityType<FossilAnalyzerBlockEntity> = this.create("fossil_analyzer",
|
val FOSSIL_ANALYZER: BlockEntityType<FossilAnalyzerBlockEntity> = this.create("fossil_analyzer",
|
||||||
BlockEntityType.Builder.of({ pos, state -> FossilAnalyzerBlockEntity(pos, state, FossilMultiblockBuilder(pos)) },
|
BlockEntityType.Builder.create({ pos, state -> FossilAnalyzerBlockEntity(pos, state, FossilMultiblockBuilder(pos)) },
|
||||||
CobblemonBlocks.FOSSIL_ANALYZER
|
CobblemonBlocks.FOSSIL_ANALYZER
|
||||||
).build(null)
|
).build(null)
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val DISPLAY_CASE: BlockEntityType<DisplayCaseBlockEntity> = this.create("display_case",
|
val DISPLAY_CASE: BlockEntityType<DisplayCaseBlockEntity> = this.create("display_case",
|
||||||
BlockEntityType.Builder.of(::DisplayCaseBlockEntity, CobblemonBlocks.DISPLAY_CASE).build(null)
|
BlockEntityType.Builder.create(::DisplayCaseBlockEntity, CobblemonBlocks.DISPLAY_CASE).build(null)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,36 +10,42 @@ package com.cobblemon.mod.common
|
|||||||
|
|
||||||
import com.cobblemon.mod.common.api.apricorn.Apricorn
|
import com.cobblemon.mod.common.api.apricorn.Apricorn
|
||||||
import com.cobblemon.mod.common.block.*
|
import com.cobblemon.mod.common.block.*
|
||||||
import com.cobblemon.mod.common.block.LecternBlock
|
|
||||||
import com.cobblemon.mod.common.block.MintBlock.MintType
|
import com.cobblemon.mod.common.block.MintBlock.MintType
|
||||||
|
import com.cobblemon.mod.common.block.FossilAnalyzerBlock
|
||||||
|
import com.cobblemon.mod.common.block.MonitorBlock
|
||||||
|
import com.cobblemon.mod.common.block.RestorationTankBlock
|
||||||
|
import com.cobblemon.mod.common.mixin.invoker.DoorBlockInvoker
|
||||||
|
import com.cobblemon.mod.common.mixin.invoker.PressurePlateBlockInvoker
|
||||||
|
import com.cobblemon.mod.common.mixin.invoker.StairsBlockInvoker
|
||||||
|
import com.cobblemon.mod.common.mixin.invoker.TrapdoorBlockInvoker
|
||||||
|
import com.cobblemon.mod.common.mixin.invoker.*
|
||||||
|
import com.cobblemon.mod.common.platform.PlatformRegistry
|
||||||
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
|
import com.cobblemon.mod.common.block.BerryBlock
|
||||||
import com.cobblemon.mod.common.block.chest.GildedChestBlock
|
import com.cobblemon.mod.common.block.chest.GildedChestBlock
|
||||||
import com.cobblemon.mod.common.block.sign.CobblemonHangingSignBlock
|
import com.cobblemon.mod.common.block.sign.CobblemonHangingSignBlock
|
||||||
import com.cobblemon.mod.common.block.sign.CobblemonSignBlock
|
import com.cobblemon.mod.common.block.sign.CobblemonSignBlock
|
||||||
import com.cobblemon.mod.common.block.sign.CobblemonWallHangingSignBlock
|
import com.cobblemon.mod.common.block.sign.CobblemonWallHangingSignBlock
|
||||||
import com.cobblemon.mod.common.block.sign.CobblemonWallSignBlock
|
import com.cobblemon.mod.common.block.sign.CobblemonWallSignBlock
|
||||||
import com.cobblemon.mod.common.mixin.invoker.*
|
import net.minecraft.block.*
|
||||||
import com.cobblemon.mod.common.platform.PlatformRegistry
|
import net.minecraft.block.enums.Instrument
|
||||||
import com.cobblemon.mod.common.util.cobblemonResource
|
import net.minecraft.block.piston.PistonBehavior
|
||||||
import net.minecraft.core.Registry
|
import net.minecraft.entity.effect.StatusEffects
|
||||||
import net.minecraft.core.registries.BuiltInRegistries
|
import net.minecraft.registry.Registries
|
||||||
import net.minecraft.core.registries.Registries
|
import net.minecraft.registry.Registry
|
||||||
import net.minecraft.resources.ResourceKey
|
import net.minecraft.registry.RegistryKey
|
||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.registry.RegistryKeys
|
||||||
import net.minecraft.util.valueproviders.UniformInt
|
import net.minecraft.sound.BlockSoundGroup
|
||||||
import net.minecraft.world.effect.MobEffects
|
import net.minecraft.util.Identifier
|
||||||
import net.minecraft.world.level.block.*
|
import net.minecraft.util.math.intprovider.UniformIntProvider
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour
|
|
||||||
import net.minecraft.world.level.block.state.properties.BlockSetType
|
|
||||||
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument
|
|
||||||
import net.minecraft.world.level.block.state.properties.WoodType
|
|
||||||
import net.minecraft.world.level.material.MapColor
|
|
||||||
import net.minecraft.world.level.material.PushReaction
|
|
||||||
|
|
||||||
@Suppress("SameParameterValue", "HasPlatformType", "MemberVisibilityCanBePrivate", "unused")
|
@Suppress("SameParameterValue", "HasPlatformType", "MemberVisibilityCanBePrivate", "unused")
|
||||||
object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<Block>>, Block>() {
|
object CobblemonBlocks : PlatformRegistry<Registry<Block>, RegistryKey<Registry<Block>>, Block>() {
|
||||||
|
|
||||||
override val registry: Registry<Block> = BuiltInRegistries.BLOCK
|
|
||||||
override val resourceKey: ResourceKey<Registry<Block>> = Registries.BLOCK
|
|
||||||
|
override val registry: Registry<Block> = Registries.BLOCK
|
||||||
|
override val registryKey: RegistryKey<Registry<Block>> = RegistryKeys.BLOCK
|
||||||
|
|
||||||
val APRICORN_BLOCK_SET_TYPE = BlockSetType("apricorn")
|
val APRICORN_BLOCK_SET_TYPE = BlockSetType("apricorn")
|
||||||
val APRICORN_WOOD_TYPE = WoodType.register(WoodType("apricorn", APRICORN_BLOCK_SET_TYPE))
|
val APRICORN_WOOD_TYPE = WoodType.register(WoodType("apricorn", APRICORN_BLOCK_SET_TYPE))
|
||||||
@@ -95,7 +101,7 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
|||||||
|
|
||||||
// Apricorns
|
// Apricorns
|
||||||
@JvmField
|
@JvmField
|
||||||
val APRICORN_LOG = log("apricorn_log", arg2 = MapColor.COLOR_BROWN)
|
val APRICORN_LOG = log("apricorn_log", arg2 = MapColor.BROWN)
|
||||||
@JvmField
|
@JvmField
|
||||||
val STRIPPED_APRICORN_LOG = log("stripped_apricorn_log")
|
val STRIPPED_APRICORN_LOG = log("stripped_apricorn_log")
|
||||||
@JvmField
|
@JvmField
|
||||||
@@ -103,47 +109,35 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
|||||||
@JvmField
|
@JvmField
|
||||||
val STRIPPED_APRICORN_WOOD = log("stripped_apricorn_wood")
|
val STRIPPED_APRICORN_WOOD = log("stripped_apricorn_wood")
|
||||||
@JvmField
|
@JvmField
|
||||||
val APRICORN_PLANKS = this.create("apricorn_planks",
|
val APRICORN_PLANKS = this.create("apricorn_planks", Block(AbstractBlock.Settings.create().mapColor(MapColor.DIRT_BROWN).instrument(Instrument.BASS).strength(2.0f, 3.0f).sounds(BlockSoundGroup.WOOD)))
|
||||||
Block(
|
|
||||||
BlockBehaviour.Properties.of().mapColor(MapColor.DIRT).instrument(NoteBlockInstrument.BASS)
|
|
||||||
.strength(2.0f, 3.0f).sound(SoundType.WOOD)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val APRICORN_LEAVES = leaves("apricorn_leaves")
|
val APRICORN_LEAVES = leaves("apricorn_leaves")
|
||||||
@JvmField
|
@JvmField
|
||||||
val APRICORN_FENCE = this.create("apricorn_fence", FenceBlock(BlockBehaviour.Properties.of().mapColor(APRICORN_PLANKS.defaultMapColor()).instrument(NoteBlockInstrument.BASS).strength(2.0f, 3.0f).sound(SoundType.WOOD)))
|
val APRICORN_FENCE = this.create("apricorn_fence", FenceBlock(AbstractBlock.Settings.create().mapColor(APRICORN_PLANKS.defaultMapColor).instrument(Instrument.BASS).strength(2.0f, 3.0f).sounds(BlockSoundGroup.WOOD)))
|
||||||
@JvmField
|
@JvmField
|
||||||
val APRICORN_FENCE_GATE = this.create("apricorn_fence_gate", FenceGateBlock(APRICORN_WOOD_TYPE, BlockBehaviour.Properties.of().mapColor(APRICORN_PLANKS.defaultMapColor()).strength(2.0f, 3.0f).sound(SoundType.WOOD)))
|
val APRICORN_FENCE_GATE = this.create("apricorn_fence_gate", FenceGateBlock(AbstractBlock.Settings.create().mapColor(APRICORN_PLANKS.defaultMapColor).instrument(Instrument.BASS).strength(2.0f, 3.0f).sounds(BlockSoundGroup.WOOD), APRICORN_WOOD_TYPE))
|
||||||
|
@JvmField // Note At the time of 1.20.0 we don't need our own BlockSetType for Apricorn wood
|
||||||
|
val APRICORN_BUTTON = this.create("apricorn_button", BlocksInvoker.createWoodenButtonBlock(BlockSetType.OAK))
|
||||||
@JvmField
|
@JvmField
|
||||||
val APRICORN_BUTTON = this.create("apricorn_button", BlocksInvoker.createWoodenButtonBlock(APRICORN_BLOCK_SET_TYPE))
|
val APRICORN_PRESSURE_PLATE = this.create("apricorn_pressure_plate", PressurePlateBlockInvoker.`cobblemon$create`(PressurePlateBlock.ActivationRule.EVERYTHING, AbstractBlock.Settings.create().mapColor(APRICORN_PLANKS.defaultMapColor).instrument(Instrument.BASS).noCollision().strength(0.5f).sounds(BlockSoundGroup.WOOD), APRICORN_BLOCK_SET_TYPE))
|
||||||
@JvmField
|
@JvmField
|
||||||
val APRICORN_PRESSURE_PLATE = this.create("apricorn_pressure_plate", PressurePlateBlockInvoker.`cobblemon$create`(APRICORN_BLOCK_SET_TYPE, BlockBehaviour.Properties.of().mapColor(APRICORN_PLANKS.defaultMapColor()).noCollission().strength(0.5f).sound(SoundType.WOOD)))
|
val APRICORN_SIGN = this.create("apricorn_sign", CobblemonSignBlock(AbstractBlock.Settings.copy(Blocks.OAK_SIGN), APRICORN_WOOD_TYPE))
|
||||||
@JvmField
|
@JvmField
|
||||||
val APRICORN_SIGN = this.create("apricorn_sign", CobblemonSignBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.OAK_SIGN), APRICORN_WOOD_TYPE))
|
val APRICORN_WALL_SIGN = this.create("apricorn_wall_sign", CobblemonWallSignBlock(AbstractBlock.Settings.copy(Blocks.OAK_WALL_SIGN), APRICORN_WOOD_TYPE))
|
||||||
|
@JvmField
|
||||||
|
val APRICORN_HANGING_SIGN = this.create("apricorn_hanging_sign", CobblemonHangingSignBlock(AbstractBlock.Settings.copy(Blocks.OAK_WALL_HANGING_SIGN), APRICORN_WOOD_TYPE))
|
||||||
|
@JvmField
|
||||||
|
val APRICORN_WALL_HANGING_SIGN = this.create("apricorn_wall_hanging_sign", CobblemonWallHangingSignBlock(AbstractBlock.Settings.copy(Blocks.OAK_HANGING_SIGN), APRICORN_WOOD_TYPE))
|
||||||
|
@JvmField
|
||||||
|
val APRICORN_SLAB = this.create("apricorn_slab", SlabBlock(AbstractBlock.Settings.create().mapColor(MapColor.OAK_TAN).instrument(Instrument.BASS).strength(2.0f, 3.0f).sounds(BlockSoundGroup.WOOD)))
|
||||||
|
@JvmField
|
||||||
|
val APRICORN_STAIRS = this.create("apricorn_stairs", StairsBlockInvoker.`cobblemon$create`(APRICORN_PLANKS.defaultState, AbstractBlock.Settings.copy(APRICORN_PLANKS)))
|
||||||
|
@JvmField
|
||||||
|
val APRICORN_DOOR = this.create("apricorn_door", DoorBlockInvoker.`cobblemon$create`(AbstractBlock.Settings.create().mapColor(APRICORN_PLANKS.defaultMapColor).instrument(Instrument.BASS).strength(3.0F).sounds(BlockSoundGroup.WOOD).nonOpaque(), APRICORN_BLOCK_SET_TYPE))
|
||||||
|
@JvmField
|
||||||
|
val APRICORN_TRAPDOOR = this.create("apricorn_trapdoor", TrapdoorBlockInvoker.`cobblemon$create`(AbstractBlock.Settings.create().mapColor(MapColor.OAK_TAN).instrument(Instrument.BASS).strength(3.0F).sounds(BlockSoundGroup.WOOD).nonOpaque().allowsSpawning { _, _, _, _ -> false }, APRICORN_BLOCK_SET_TYPE))
|
||||||
|
|
||||||
@JvmField //if you wonder why we don't copy of OAK_WALL_SIGN, then I can tell you its because it uses Properties#dropsLike to point to the SIGN loot table, but we cant use that in our setup due to a deeper rooted issue, so falling back to this and writing dedicated (duplicated) loot tables
|
private val PLANT_PROPERTIES = AbstractBlock.Settings.create().mapColor(MapColor.DARK_GREEN).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.GRASS).pistonBehavior(PistonBehavior.DESTROY)
|
||||||
val APRICORN_WALL_SIGN = this.create(
|
|
||||||
"apricorn_wall_sign",
|
|
||||||
CobblemonWallSignBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.OAK_SIGN), APRICORN_WOOD_TYPE)
|
|
||||||
)
|
|
||||||
@JvmField
|
|
||||||
val APRICORN_HANGING_SIGN = this.create(
|
|
||||||
"apricorn_hanging_sign",
|
|
||||||
CobblemonHangingSignBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.OAK_HANGING_SIGN), APRICORN_WOOD_TYPE)
|
|
||||||
)
|
|
||||||
@JvmField
|
|
||||||
val APRICORN_WALL_HANGING_SIGN = this.create("apricorn_wall_hanging_sign", CobblemonWallHangingSignBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.OAK_HANGING_SIGN), APRICORN_WOOD_TYPE))
|
|
||||||
@JvmField
|
|
||||||
val APRICORN_SLAB = this.create("apricorn_slab", SlabBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).instrument(NoteBlockInstrument.BASS).strength(2.0f, 3.0f).sound(SoundType.WOOD)))
|
|
||||||
@JvmField
|
|
||||||
val APRICORN_STAIRS = this.create("apricorn_stairs", StairsBlockInvoker.`cobblemon$create`(APRICORN_PLANKS.defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(APRICORN_PLANKS)))
|
|
||||||
@JvmField
|
|
||||||
val APRICORN_DOOR = this.create("apricorn_door", DoorBlockInvoker.`cobblemon$create`(APRICORN_BLOCK_SET_TYPE, BlockBehaviour.Properties.of().mapColor(APRICORN_PLANKS.defaultMapColor()).instrument(NoteBlockInstrument.BASS).strength(3.0F).sound(SoundType.WOOD).noOcclusion()))
|
|
||||||
@JvmField
|
|
||||||
val APRICORN_TRAPDOOR = this.create("apricorn_trapdoor", TrapdoorBlockInvoker.`cobblemon$create`(APRICORN_BLOCK_SET_TYPE, BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).instrument(NoteBlockInstrument.BASS).strength(3.0F).sound(SoundType.WOOD).noOcclusion().isValidSpawn { _, _, _, _ -> false }))
|
|
||||||
|
|
||||||
private val PLANT_PROPERTIES = BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).noCollission().randomTicks().instabreak().sound(SoundType.GRASS).pushReaction(PushReaction.DESTROY)
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val BLACK_APRICORN_SAPLING = this.create("black_apricorn_sapling", ApricornSaplingBlock(PLANT_PROPERTIES, Apricorn.BLACK))
|
val BLACK_APRICORN_SAPLING = this.create("black_apricorn_sapling", ApricornSaplingBlock(PLANT_PROPERTIES, Apricorn.BLACK))
|
||||||
@JvmField
|
@JvmField
|
||||||
@@ -160,13 +154,13 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
|||||||
val YELLOW_APRICORN_SAPLING = this.create("yellow_apricorn_sapling", ApricornSaplingBlock(PLANT_PROPERTIES, Apricorn.YELLOW))
|
val YELLOW_APRICORN_SAPLING = this.create("yellow_apricorn_sapling", ApricornSaplingBlock(PLANT_PROPERTIES, Apricorn.YELLOW))
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val MEDICINAL_LEEK = this.create("medicinal_leek", MedicinalLeekBlock(BlockBehaviour.Properties.of().pushReaction(PushReaction.DESTROY).ignitedByLava().mapColor(MapColor.CRIMSON_NYLIUM).noCollission().randomTicks().instabreak().sound(CobblemonSounds.MEDICINAL_LEEK_SOUNDS)))
|
val MEDICINAL_LEEK = this.create("medicinal_leek", MedicinalLeekBlock(AbstractBlock.Settings.create().pistonBehavior(PistonBehavior.DESTROY).burnable().mapColor(MapColor.DULL_RED).noCollision().ticksRandomly().breakInstantly().sounds(CobblemonSounds.MEDICINAL_LEEK_SOUNDS)))
|
||||||
@JvmField
|
@JvmField
|
||||||
val ENERGY_ROOT = this.create("energy_root", EnergyRootBlock(BlockBehaviour.Properties.of().pushReaction(PushReaction.DESTROY).ignitedByLava().mapColor(MapColor.DIRT).noCollission().randomTicks().instabreak().sound(CobblemonSounds.ENERGY_ROOT_SOUNDS)))
|
val ENERGY_ROOT = this.create("energy_root", EnergyRootBlock(AbstractBlock.Settings.create().pistonBehavior(PistonBehavior.DESTROY).burnable().mapColor(MapColor.DIRT_BROWN).noCollision().ticksRandomly().breakInstantly().sounds(CobblemonSounds.ENERGY_ROOT_SOUNDS)))
|
||||||
@JvmField
|
@JvmField
|
||||||
val BIG_ROOT = this.create("big_root", BigRootBlock(BlockBehaviour.Properties.of().pushReaction(PushReaction.DESTROY).ignitedByLava().mapColor(MapColor.PLANT).noCollission().randomTicks().instabreak().sound(CobblemonSounds.BIG_ROOT_SOUNDS)))
|
val BIG_ROOT = this.create("big_root", BigRootBlock(AbstractBlock.Settings.create().pistonBehavior(PistonBehavior.DESTROY).burnable().mapColor(MapColor.DARK_GREEN).noCollision().ticksRandomly().breakInstantly().sounds(CobblemonSounds.BIG_ROOT_SOUNDS)))
|
||||||
@JvmField
|
@JvmField
|
||||||
val REVIVAL_HERB = this.create("revival_herb", RevivalHerbBlock(BlockBehaviour.Properties.of().pushReaction(PushReaction.DESTROY).mapColor(MapColor.PLANT).ignitedByLava().noCollission().instabreak().sound(CobblemonSounds.REVIVAL_HERB_SOUNDS)))
|
val REVIVAL_HERB = this.create("revival_herb", RevivalHerbBlock(AbstractBlock.Settings.create().pistonBehavior(PistonBehavior.DESTROY).mapColor(MapColor.DARK_GREEN).burnable().noCollision().breakInstantly().sounds(BlockSoundGroup.CROP)))
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val TUMBLESTONE_CLUSTER = tumblestoneBlock("tumblestone_cluster", GrowableStoneBlock.STAGE_3, 7, 3, null)
|
val TUMBLESTONE_CLUSTER = tumblestoneBlock("tumblestone_cluster", GrowableStoneBlock.STAGE_3, 7, 3, null)
|
||||||
@@ -196,113 +190,29 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
|||||||
val SMALL_BUDDING_BLACK_TUMBLESTONE = tumblestoneBlock("small_budding_black_tumblestone", GrowableStoneBlock.STAGE_0, 3, 4, MEDIUM_BUDDING_BLACK_TUMBLESTONE)
|
val SMALL_BUDDING_BLACK_TUMBLESTONE = tumblestoneBlock("small_budding_black_tumblestone", GrowableStoneBlock.STAGE_0, 3, 4, MEDIUM_BUDDING_BLACK_TUMBLESTONE)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val TUMBLESTONE_BLOCK = this.create("tumblestone_block", Block(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_ORANGE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
val TUMBLESTONE_BLOCK = this.create("tumblestone_block", Block(AbstractBlock.Settings.create()
|
||||||
|
.mapColor(MapColor.TERRACOTTA_ORANGE)
|
||||||
|
.strength(1.0F)
|
||||||
|
.sounds(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS)
|
||||||
|
.requiresTool()
|
||||||
|
.instrument(Instrument.BASEDRUM)
|
||||||
|
))
|
||||||
@JvmField
|
@JvmField
|
||||||
val SKY_TUMBLESTONE_BLOCK = this.create("sky_tumblestone_block", Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
val SKY_TUMBLESTONE_BLOCK = this.create("sky_tumblestone_block", Block(AbstractBlock.Settings.create()
|
||||||
|
.mapColor(MapColor.LIGHT_BLUE)
|
||||||
|
.strength(1.0F)
|
||||||
|
.sounds(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS)
|
||||||
|
.requiresTool()
|
||||||
|
.instrument(Instrument.BASEDRUM)
|
||||||
|
))
|
||||||
@JvmField
|
@JvmField
|
||||||
val BLACK_TUMBLESTONE_BLOCK = this.create("black_tumblestone_block", Block(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_BLACK).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
val BLACK_TUMBLESTONE_BLOCK = this.create("black_tumblestone_block", Block(AbstractBlock.Settings.create()
|
||||||
|
.mapColor(MapColor.TERRACOTTA_BLACK)
|
||||||
@JvmField
|
.strength(1.0F)
|
||||||
val POLISHED_TUMBLESTONE = this.create("polished_tumblestone", Block(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_ORANGE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
.sounds(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS)
|
||||||
@JvmField
|
.requiresTool()
|
||||||
val POLISHED_TUMBLESTONE_STAIRS = this.create("polished_tumblestone_stairs", StairsBlockInvoker.`cobblemon$create`(POLISHED_TUMBLESTONE.defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(POLISHED_TUMBLESTONE)))
|
.instrument(Instrument.BASEDRUM)
|
||||||
@JvmField
|
))
|
||||||
val POLISHED_TUMBLESTONE_SLAB = this.create("polished_tumblestone_slab", SlabBlock(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_ORANGE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_TUMBLESTONE_WALL = this.create("polished_tumblestone_wall", WallBlock(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_ORANGE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val CHISELED_POLISHED_TUMBLESTONE = this.create("chiseled_polished_tumblestone", Block(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_ORANGE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_TUMBLESTONE = this.create("smooth_tumblestone", Block(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_ORANGE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_TUMBLESTONE_STAIRS = this.create("smooth_tumblestone_stairs", StairsBlockInvoker.`cobblemon$create`(SMOOTH_TUMBLESTONE.defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(SMOOTH_TUMBLESTONE)))
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_TUMBLESTONE_SLAB = this.create("smooth_tumblestone_slab", SlabBlock(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_ORANGE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val TUMBLESTONE_BRICKS = this.create("tumblestone_bricks", Block(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_ORANGE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val TUMBLESTONE_BRICK_STAIRS = this.create("tumblestone_brick_stairs", StairsBlockInvoker.`cobblemon$create`(TUMBLESTONE_BRICKS.defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(TUMBLESTONE_BRICKS)))
|
|
||||||
@JvmField
|
|
||||||
val TUMBLESTONE_BRICK_SLAB = this.create("tumblestone_brick_slab", SlabBlock(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_ORANGE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val TUMBLESTONE_BRICK_WALL = this.create("tumblestone_brick_wall", WallBlock(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_ORANGE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val CHISELED_TUMBLESTONE_BRICKS = this.create("chiseled_tumblestone_bricks", Block(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_ORANGE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_SKY_TUMBLESTONE = this.create("polished_sky_tumblestone", Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_SKY_TUMBLESTONE_STAIRS = this.create("polished_sky_tumblestone_stairs", StairsBlockInvoker.`cobblemon$create`(POLISHED_SKY_TUMBLESTONE.defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(POLISHED_SKY_TUMBLESTONE)))
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_SKY_TUMBLESTONE_SLAB = this.create("polished_sky_tumblestone_slab", SlabBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_SKY_TUMBLESTONE_WALL = this.create("polished_sky_tumblestone_wall", WallBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val CHISELED_POLISHED_SKY_TUMBLESTONE = this.create("chiseled_polished_sky_tumblestone", Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_SKY_TUMBLESTONE = this.create("smooth_sky_tumblestone", Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_SKY_TUMBLESTONE_STAIRS = this.create("smooth_sky_tumblestone_stairs", StairsBlockInvoker.`cobblemon$create`(SMOOTH_SKY_TUMBLESTONE.defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(SMOOTH_SKY_TUMBLESTONE)))
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_SKY_TUMBLESTONE_SLAB = this.create("smooth_sky_tumblestone_slab", SlabBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val SKY_TUMBLESTONE_BRICKS = this.create("sky_tumblestone_bricks", Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val SKY_TUMBLESTONE_BRICK_STAIRS = this.create("sky_tumblestone_brick_stairs", StairsBlockInvoker.`cobblemon$create`(SKY_TUMBLESTONE_BRICKS.defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(SKY_TUMBLESTONE_BRICKS)))
|
|
||||||
@JvmField
|
|
||||||
val SKY_TUMBLESTONE_BRICK_SLAB = this.create("sky_tumblestone_brick_slab", SlabBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val SKY_TUMBLESTONE_BRICK_WALL = this.create("sky_tumblestone_brick_wall", WallBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val CHISELED_SKY_TUMBLESTONE_BRICKS = this.create("chiseled_sky_tumblestone_bricks", Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_BLACK_TUMBLESTONE = this.create("polished_black_tumblestone", Block(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_BLACK).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_BLACK_TUMBLESTONE_STAIRS = this.create("polished_black_tumblestone_stairs", StairsBlockInvoker.`cobblemon$create`(POLISHED_BLACK_TUMBLESTONE.defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(POLISHED_BLACK_TUMBLESTONE)))
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_BLACK_TUMBLESTONE_SLAB = this.create("polished_black_tumblestone_slab", SlabBlock(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_BLACK).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_BLACK_TUMBLESTONE_WALL = this.create("polished_black_tumblestone_wall", WallBlock(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_BLACK).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val CHISELED_POLISHED_BLACK_TUMBLESTONE = this.create("chiseled_polished_black_tumblestone", Block(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_BLACK).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_BLACK_TUMBLESTONE = this.create("smooth_black_tumblestone", Block(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_BLACK).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_BLACK_TUMBLESTONE_STAIRS = this.create("smooth_black_tumblestone_stairs", StairsBlockInvoker.`cobblemon$create`(SMOOTH_BLACK_TUMBLESTONE.defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(SMOOTH_BLACK_TUMBLESTONE)))
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_BLACK_TUMBLESTONE_SLAB = this.create("smooth_black_tumblestone_slab", SlabBlock(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_BLACK).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val BLACK_TUMBLESTONE_BRICKS = this.create("black_tumblestone_bricks", Block(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_BLACK).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val BLACK_TUMBLESTONE_BRICK_STAIRS = this.create("black_tumblestone_brick_stairs", StairsBlockInvoker.`cobblemon$create`(BLACK_TUMBLESTONE_BRICKS.defaultBlockState(), BlockBehaviour.Properties.ofFullCopy(BLACK_TUMBLESTONE_BRICKS)))
|
|
||||||
@JvmField
|
|
||||||
val BLACK_TUMBLESTONE_BRICK_SLAB = this.create("black_tumblestone_brick_slab", SlabBlock(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_BLACK).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val BLACK_TUMBLESTONE_BRICK_WALL = this.create("black_tumblestone_brick_wall", WallBlock(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_BLACK).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
@JvmField
|
|
||||||
val CHISELED_BLACK_TUMBLESTONE_BRICKS = this.create("chiseled_black_tumblestone_bricks", Block(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_BLACK).strength(1.0F).sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BASEDRUM)))
|
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val FIRE_STONE_BLOCK = this.create("fire_stone_block", Block(BlockBehaviour.Properties.of().mapColor(MapColor.FIRE).strength(1.0F).sound(CobblemonSounds.EVOLUTION_STONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BIT).lightLevel{13}))
|
|
||||||
@JvmField
|
|
||||||
val WATER_STONE_BLOCK = this.create("water_stone_block", Block(BlockBehaviour.Properties.of().mapColor(MapColor.WATER).strength(1.0F).sound(CobblemonSounds.EVOLUTION_STONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BIT)))
|
|
||||||
@JvmField
|
|
||||||
val THUNDER_STONE_BLOCK = this.create("thunder_stone_block", Block(BlockBehaviour.Properties.of().mapColor(MapColor.GLOW_LICHEN).strength(1.0F).sound(CobblemonSounds.EVOLUTION_STONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BIT).lightLevel{8}))
|
|
||||||
@JvmField
|
|
||||||
val LEAF_STONE_BLOCK = this.create("leaf_stone_block", Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_GREEN).strength(1.0F).sound(CobblemonSounds.EVOLUTION_STONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BIT)))
|
|
||||||
@JvmField
|
|
||||||
val ICE_STONE_BLOCK = this.create("ice_stone_block", Block(BlockBehaviour.Properties.of().mapColor(MapColor.ICE).strength(1.0F).sound(CobblemonSounds.EVOLUTION_STONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BIT)))
|
|
||||||
@JvmField
|
|
||||||
val SUN_STONE_BLOCK = this.create("sun_stone_block", Block(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_ORANGE).strength(1.0F).sound(CobblemonSounds.EVOLUTION_STONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BIT).lightLevel{5}))
|
|
||||||
@JvmField
|
|
||||||
val MOON_STONE_BLOCK = this.create("moon_stone_block", Block(BlockBehaviour.Properties.of().mapColor(MapColor.DEEPSLATE).strength(1.0F).sound(CobblemonSounds.EVOLUTION_STONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BIT)))
|
|
||||||
@JvmField
|
|
||||||
val SHINY_STONE_BLOCK = this.create("shiny_stone_block", Block(BlockBehaviour.Properties.of().mapColor(MapColor.QUARTZ).strength(1.0F).sound(CobblemonSounds.EVOLUTION_STONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BIT).lightLevel{15}))
|
|
||||||
@JvmField
|
|
||||||
val DAWN_STONE_BLOCK = this.create("dawn_stone_block", Block(BlockBehaviour.Properties.of().mapColor(MapColor.DIAMOND).strength(1.0F).sound(CobblemonSounds.EVOLUTION_STONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BIT).lightLevel{15}))
|
|
||||||
@JvmField
|
|
||||||
val DUSK_STONE_BLOCK = this.create("dusk_stone_block", Block(BlockBehaviour.Properties.of().mapColor(MapColor.WARPED_HYPHAE).strength(1.0F).sound(CobblemonSounds.EVOLUTION_STONE_BLOCK_SOUNDS).requiresCorrectToolForDrops().instrument(NoteBlockInstrument.BIT)))
|
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val BLACK_APRICORN = apricornBlock("black_apricorn", Apricorn.BLACK)
|
val BLACK_APRICORN = apricornBlock("black_apricorn", Apricorn.BLACK)
|
||||||
@@ -320,65 +230,207 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
|||||||
val YELLOW_APRICORN = apricornBlock("yellow_apricorn", Apricorn.YELLOW)
|
val YELLOW_APRICORN = apricornBlock("yellow_apricorn", Apricorn.YELLOW)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val RELIC_COIN_POUCH = create("relic_coin_pouch", CoinPouchBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.RELIC_COIN_POUCH_SOUNDS).pushReaction(PushReaction.DESTROY).noOcclusion(), true))
|
val RELIC_COIN_POUCH = create(
|
||||||
|
"relic_coin_pouch",
|
||||||
|
CoinPouchBlock(
|
||||||
|
AbstractBlock.Settings.create()
|
||||||
|
.sounds(CobblemonSounds.COIN_POUCH_SOUNDS)
|
||||||
|
.pistonBehavior(PistonBehavior.DESTROY)
|
||||||
|
.strength(0.4f)
|
||||||
|
.nonOpaque(), true
|
||||||
|
)
|
||||||
|
)
|
||||||
@JvmField
|
@JvmField
|
||||||
val RELIC_COIN_SACK = create("relic_coin_sack", CoinPouchBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.RELIC_COIN_SACK_SOUNDS).pushReaction(PushReaction.DESTROY).strength(0.4f), false))
|
val RELIC_COIN_SACK = create(
|
||||||
|
"relic_coin_sack",
|
||||||
|
CoinPouchBlock(
|
||||||
|
AbstractBlock.Settings.create()
|
||||||
|
.sounds(CobblemonSounds.COIN_POUCH_SOUNDS)
|
||||||
|
.pistonBehavior(PistonBehavior.DESTROY)
|
||||||
|
.strength(0.4f), false
|
||||||
|
))
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val GILDED_CHEST = create("gilded_chest", GildedChestBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.CHEST).noOcclusion().sound(CobblemonSounds.GILDED_CHEST_SOUNDS), GildedChestBlock.Type.RED))
|
val GILDED_CHEST = create(
|
||||||
@JvmField
|
"gilded_chest",
|
||||||
val BLUE_GILDED_CHEST = create("blue_gilded_chest", GildedChestBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.CHEST).noOcclusion().sound(CobblemonSounds.GILDED_CHEST_SOUNDS), GildedChestBlock.Type.BLUE))
|
GildedChestBlock(
|
||||||
@JvmField
|
AbstractBlock.Settings.copy(Blocks.CHEST).nonOpaque().sounds(CobblemonSounds.GILDED_CHEST_SOUNDS),
|
||||||
val BLACK_GILDED_CHEST = create("black_gilded_chest", GildedChestBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.CHEST).noOcclusion().sound(CobblemonSounds.GILDED_CHEST_SOUNDS), GildedChestBlock.Type.BLACK))
|
GildedChestBlock.Type.RED
|
||||||
@JvmField
|
)
|
||||||
val YELLOW_GILDED_CHEST = create("yellow_gilded_chest", GildedChestBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.CHEST).noOcclusion().sound(CobblemonSounds.GILDED_CHEST_SOUNDS), GildedChestBlock.Type.YELLOW))
|
)
|
||||||
@JvmField
|
|
||||||
val WHITE_GILDED_CHEST = create("white_gilded_chest", GildedChestBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.CHEST).noOcclusion().sound(CobblemonSounds.GILDED_CHEST_SOUNDS), GildedChestBlock.Type.WHITE))
|
|
||||||
@JvmField
|
|
||||||
val GREEN_GILDED_CHEST = create("green_gilded_chest", GildedChestBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.CHEST).noOcclusion().sound(CobblemonSounds.GILDED_CHEST_SOUNDS), GildedChestBlock.Type.GREEN))
|
|
||||||
@JvmField
|
|
||||||
val PINK_GILDED_CHEST = create("pink_gilded_chest", GildedChestBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.CHEST).noOcclusion().sound(CobblemonSounds.GILDED_CHEST_SOUNDS), GildedChestBlock.Type.PINK))
|
|
||||||
@JvmField
|
|
||||||
val GIMMIGHOUL_CHEST = create("gimmighoul_chest", GildedChestBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.CHEST).noOcclusion().sound(CobblemonSounds.GILDED_CHEST_SOUNDS), GildedChestBlock.Type.FAKE))
|
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val MONITOR = create("monitor", MonitorBlock(BlockBehaviour.Properties.of().mapColor(MapColor.METAL).sound(SoundType.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().strength(5.0F, 6.0F).lightLevel { if (it.getValue(MonitorBlock.SCREEN) != MonitorBlock.MonitorScreen.OFF) 15 else 0 }))
|
val BLUE_GILDED_CHEST = create(
|
||||||
@JvmField
|
"blue_gilded_chest",
|
||||||
val FOSSIL_ANALYZER = create("fossil_analyzer", FossilAnalyzerBlock(BlockBehaviour.Properties.of().mapColor(MapColor.METAL).sound(SoundType.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().strength(5.0F, 6.0F).noOcclusion()))
|
GildedChestBlock(
|
||||||
@JvmField
|
AbstractBlock.Settings.copy(Blocks.CHEST).nonOpaque().sounds(CobblemonSounds.GILDED_CHEST_SOUNDS),
|
||||||
val RESTORATION_TANK = create("restoration_tank", RestorationTankBlock(BlockBehaviour.Properties.of().mapColor(MapColor.METAL).sound(SoundType.GLASS).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().strength(5.0F, 6.0F).noOcclusion()))
|
GildedChestBlock.Type.BLUE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val HEALING_MACHINE = create("healing_machine", HealingMachineBlock(BlockBehaviour.Properties.of().mapColor(MapColor.METAL).sound(SoundType.METAL).pushReaction(PushReaction.BLOCK).strength(2f).noOcclusion().lightLevel { if (it.getValue(HealingMachineBlock.CHARGE_LEVEL) >= HealingMachineBlock.MAX_CHARGE_LEVEL) 7 else 2 }))
|
val BLACK_GILDED_CHEST = create(
|
||||||
|
"black_gilded_chest",
|
||||||
|
GildedChestBlock(
|
||||||
|
AbstractBlock.Settings.copy(Blocks.CHEST).nonOpaque().sounds(CobblemonSounds.GILDED_CHEST_SOUNDS),
|
||||||
|
GildedChestBlock.Type.BLACK
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val PC = create("pc", PCBlock(BlockBehaviour.Properties.of().mapColor(MapColor.METAL).sound(SoundType.METAL).pushReaction(PushReaction.BLOCK).strength(2F).noOcclusion().lightLevel { if ((it.getValue(PCBlock.ON) as Boolean) && (it.getValue(PCBlock.PART) == PCBlock.PCPart.TOP)) 10 else 0 }))
|
val YELLOW_GILDED_CHEST = create(
|
||||||
|
"yellow_gilded_chest",
|
||||||
|
GildedChestBlock(
|
||||||
|
AbstractBlock.Settings.copy(Blocks.CHEST).nonOpaque().sounds(CobblemonSounds.GILDED_CHEST_SOUNDS),
|
||||||
|
GildedChestBlock.Type.YELLOW
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val LECTERN = create("lectern", LecternBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).instrument(NoteBlockInstrument.BASS).sound(SoundType.WOOD).strength(2.5F).ignitedByLava()))
|
val WHITE_GILDED_CHEST = create(
|
||||||
|
"white_gilded_chest",
|
||||||
|
GildedChestBlock(
|
||||||
|
AbstractBlock.Settings.copy(Blocks.CHEST).nonOpaque().sounds(CobblemonSounds.GILDED_CHEST_SOUNDS),
|
||||||
|
GildedChestBlock.Type.WHITE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val DISPLAY_CASE = create("display_case", DisplayCaseBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.DISPLAY_CASE_SOUNDS).noOcclusion().pushReaction(PushReaction.BLOCK).mapColor(MapColor.STONE).strength(0.3F)))
|
val GREEN_GILDED_CHEST = create(
|
||||||
|
"green_gilded_chest",
|
||||||
|
GildedChestBlock(
|
||||||
|
AbstractBlock.Settings.copy(Blocks.CHEST).nonOpaque().sounds(CobblemonSounds.GILDED_CHEST_SOUNDS),
|
||||||
|
GildedChestBlock.Type.GREEN
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val PASTURE = create("pasture", PastureBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BROWN).sound(SoundType.WOOD).strength(2F).noOcclusion().pushReaction(PushReaction.BLOCK).lightLevel { if ((it.getValue(PastureBlock.ON) as Boolean) && (it.getValue(PastureBlock.PART) == PastureBlock.PasturePart.TOP)) 10 else 0 }))
|
val PINK_GILDED_CHEST = create(
|
||||||
|
"pink_gilded_chest",
|
||||||
val RED_MINT = create("red_mint", MintBlock(MintType.RED, BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED).noCollission().randomTicks().instabreak().sound(CobblemonSounds.MINT_SOUNDS).pushReaction(PushReaction.DESTROY)))
|
GildedChestBlock(
|
||||||
@JvmField
|
AbstractBlock.Settings.copy(Blocks.CHEST).nonOpaque().sounds(CobblemonSounds.GILDED_CHEST_SOUNDS),
|
||||||
val BLUE_MINT = create("blue_mint", MintBlock(MintType.BLUE, BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLUE).noCollission().randomTicks().instabreak().sound(CobblemonSounds.MINT_SOUNDS).pushReaction(PushReaction.DESTROY)))
|
GildedChestBlock.Type.PINK
|
||||||
@JvmField
|
)
|
||||||
val CYAN_MINT = create("cyan_mint", MintBlock(MintType.CYAN, BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_CYAN).noCollission().randomTicks().instabreak().sound(CobblemonSounds.MINT_SOUNDS).pushReaction(PushReaction.DESTROY)))
|
)
|
||||||
@JvmField
|
|
||||||
val PINK_MINT = create("pink_mint", MintBlock(MintType.PINK, BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_PINK).noCollission().randomTicks().instabreak().sound(CobblemonSounds.MINT_SOUNDS).pushReaction(PushReaction.DESTROY)))
|
|
||||||
@JvmField
|
|
||||||
val GREEN_MINT = create("green_mint", MintBlock(MintType.GREEN, BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_GREEN).noCollission().randomTicks().instabreak().sound(CobblemonSounds.MINT_SOUNDS).pushReaction(PushReaction.DESTROY)))
|
|
||||||
@JvmField
|
|
||||||
val WHITE_MINT = create("white_mint", MintBlock(MintType.WHITE, BlockBehaviour.Properties.of().mapColor(MapColor.SNOW).noCollission().randomTicks().instabreak().sound(CobblemonSounds.MINT_SOUNDS).pushReaction(PushReaction.DESTROY)))
|
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val VIVICHOKE_SEEDS = this.create("vivichoke_seeds", VivichokeBlock(BlockBehaviour.Properties.of().pushReaction(PushReaction.DESTROY).ignitedByLava().mapColor(MapColor.PLANT).noCollission().randomTicks().instabreak().sound(CobblemonSounds.VIVICHOKE_SOUNDS)))
|
val GIMMIGHOUL_CHEST = create(
|
||||||
|
"gimmighoul_chest",
|
||||||
|
GildedChestBlock(
|
||||||
|
AbstractBlock.Settings.copy(Blocks.CHEST).nonOpaque().sounds(CobblemonSounds.GILDED_CHEST_SOUNDS),
|
||||||
|
GildedChestBlock.Type.FAKE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val PEP_UP_FLOWER = this.create("pep_up_flower", FlowerBlock(MobEffects.LEVITATION, 10F, BlockBehaviour.Properties.of().mapColor(MapColor.PLANT).noCollission().instabreak().sound(SoundType.GRASS).offsetType(BlockBehaviour.OffsetType.XZ).pushReaction(PushReaction.DESTROY)))
|
val MONITOR = create(
|
||||||
|
"monitor",
|
||||||
|
MonitorBlock(
|
||||||
|
AbstractBlock.Settings.create()
|
||||||
|
.mapColor(MapColor.IRON_GRAY)
|
||||||
|
.sounds(BlockSoundGroup.METAL)
|
||||||
|
.pistonBehavior(PistonBehavior.BLOCK)
|
||||||
|
.requiresTool()
|
||||||
|
.strength(5.0F, 6.0F)
|
||||||
|
.luminance { if (it.get(MonitorBlock.SCREEN) != MonitorBlock.MonitorScreen.OFF) 15 else 0 }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
@JvmField
|
||||||
|
val FOSSIL_ANALYZER = create(
|
||||||
|
"fossil_analyzer",
|
||||||
|
FossilAnalyzerBlock(
|
||||||
|
AbstractBlock.Settings.create()
|
||||||
|
.mapColor(MapColor.IRON_GRAY)
|
||||||
|
.sounds(BlockSoundGroup.METAL)
|
||||||
|
.pistonBehavior(PistonBehavior.BLOCK)
|
||||||
|
.requiresTool()
|
||||||
|
.strength(5.0F, 6.0F)
|
||||||
|
.nonOpaque()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
@JvmField
|
||||||
|
val RESTORATION_TANK = create(
|
||||||
|
"restoration_tank",
|
||||||
|
RestorationTankBlock(
|
||||||
|
AbstractBlock.Settings.create()
|
||||||
|
.mapColor(MapColor.IRON_GRAY)
|
||||||
|
.sounds(BlockSoundGroup.GLASS)
|
||||||
|
.pistonBehavior(PistonBehavior.BLOCK)
|
||||||
|
.requiresTool()
|
||||||
|
.strength(5.0F, 6.0F)
|
||||||
|
.nonOpaque()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
@JvmField
|
||||||
|
val HEALING_MACHINE = create(
|
||||||
|
"healing_machine",
|
||||||
|
HealingMachineBlock(
|
||||||
|
AbstractBlock.Settings.create()
|
||||||
|
.mapColor(MapColor.IRON_GRAY)
|
||||||
|
.sounds(BlockSoundGroup.METAL)
|
||||||
|
.pistonBehavior(PistonBehavior.BLOCK)
|
||||||
|
.strength(2f)
|
||||||
|
.nonOpaque()
|
||||||
|
.luminance { if (it.get(HealingMachineBlock.CHARGE_LEVEL) >= HealingMachineBlock.MAX_CHARGE_LEVEL) 7 else 2 }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
@JvmField
|
||||||
|
val PC = create(
|
||||||
|
"pc",
|
||||||
|
PCBlock(
|
||||||
|
AbstractBlock.Settings.create()
|
||||||
|
.mapColor(MapColor.IRON_GRAY)
|
||||||
|
.sounds(BlockSoundGroup.METAL)
|
||||||
|
.pistonBehavior(PistonBehavior.BLOCK)
|
||||||
|
.strength(2F)
|
||||||
|
.nonOpaque()
|
||||||
|
.luminance { if ((it.get(PCBlock.ON) as Boolean) && (it.get(PCBlock.PART) == PCBlock.PCPart.TOP)) 10 else 0 }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
@JvmField
|
||||||
|
val DISPLAY_CASE = create(
|
||||||
|
"display_case",
|
||||||
|
DisplayCaseBlock(
|
||||||
|
AbstractBlock.Settings.create()
|
||||||
|
.sounds(CobblemonSounds.DISPLAY_CASE_SOUNDS)
|
||||||
|
.nonOpaque()
|
||||||
|
.pistonBehavior(PistonBehavior.BLOCK)
|
||||||
|
.mapColor(MapColor.STONE_GRAY)
|
||||||
|
.strength(0.3f)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
val RED_MINT = create("red_mint", MintBlock(MintType.RED, AbstractBlock.Settings.create().mapColor(MapColor.RED).noCollision().ticksRandomly().breakInstantly().sounds(CobblemonSounds.MINT_SOUNDS)))
|
||||||
|
@JvmField
|
||||||
|
val BLUE_MINT = create("blue_mint", MintBlock(MintType.BLUE, AbstractBlock.Settings.create().mapColor(MapColor.BLUE).noCollision().ticksRandomly().breakInstantly().sounds(CobblemonSounds.MINT_SOUNDS)))
|
||||||
|
@JvmField
|
||||||
|
val CYAN_MINT = create("cyan_mint", MintBlock(MintType.CYAN, AbstractBlock.Settings.create().mapColor(MapColor.CYAN).noCollision().ticksRandomly().breakInstantly().sounds(CobblemonSounds.MINT_SOUNDS)))
|
||||||
|
@JvmField
|
||||||
|
val PINK_MINT = create("pink_mint", MintBlock(MintType.PINK, AbstractBlock.Settings.create().mapColor(MapColor.PINK).noCollision().ticksRandomly().breakInstantly().sounds(CobblemonSounds.MINT_SOUNDS)))
|
||||||
|
@JvmField
|
||||||
|
val GREEN_MINT = create("green_mint", MintBlock(MintType.GREEN, AbstractBlock.Settings.create().mapColor(MapColor.GREEN).noCollision().ticksRandomly().breakInstantly().sounds(CobblemonSounds.MINT_SOUNDS)))
|
||||||
|
@JvmField
|
||||||
|
val WHITE_MINT = create("white_mint", MintBlock(MintType.WHITE, AbstractBlock.Settings.create().mapColor(MapColor.WHITE).noCollision().ticksRandomly().breakInstantly().sounds(CobblemonSounds.MINT_SOUNDS)))
|
||||||
|
|
||||||
|
@JvmField
|
||||||
|
val PASTURE = create(
|
||||||
|
"pasture",
|
||||||
|
PastureBlock(
|
||||||
|
AbstractBlock.Settings.create()
|
||||||
|
.mapColor(MapColor.BROWN)
|
||||||
|
.sounds(BlockSoundGroup.WOOD)
|
||||||
|
.strength(2F)
|
||||||
|
.nonOpaque()
|
||||||
|
.pistonBehavior(PistonBehavior.BLOCK)
|
||||||
|
.luminance { if ((it.get(PastureBlock.ON) as Boolean) && (it.get(PastureBlock.PART) == PastureBlock.PasturePart.TOP)) 10 else 0 }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
@JvmField
|
||||||
|
val VIVICHOKE_SEEDS = this.create("vivichoke_seeds", VivichokeBlock(AbstractBlock.Settings.create().pistonBehavior(PistonBehavior.DESTROY).burnable().mapColor(MapColor.DARK_GREEN).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP)))
|
||||||
|
@JvmField
|
||||||
|
val PEP_UP_FLOWER = this.create("pep_up_flower", FlowerBlock(StatusEffects.LEVITATION, 10, AbstractBlock.Settings.create().mapColor(MapColor.DARK_GREEN).noCollision().breakInstantly().sounds(BlockSoundGroup.GRASS).offset(AbstractBlock.OffsetType.XZ).pistonBehavior(PistonBehavior.DESTROY)))
|
||||||
@JvmField
|
@JvmField
|
||||||
val POTTED_PEP_UP_FLOWER = this.create("potted_pep_up_flower", BlocksInvoker.createFlowerPotBlock(PEP_UP_FLOWER))
|
val POTTED_PEP_UP_FLOWER = this.create("potted_pep_up_flower", BlocksInvoker.createFlowerPotBlock(PEP_UP_FLOWER))
|
||||||
|
|
||||||
@@ -394,18 +446,18 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private fun apricornBlock(name: String, apricorn: Apricorn): ApricornBlock = this.create(name, ApricornBlock(BlockBehaviour.Properties.of().mapColor(apricorn.mapColor()).randomTicks().strength(Blocks.OAK_LOG.defaultDestroyTime(), Blocks.OAK_LOG.explosionResistance).sound(SoundType.WOOD).noOcclusion(), apricorn))
|
private fun apricornBlock(name: String, apricorn: Apricorn): ApricornBlock = this.create(name, ApricornBlock(AbstractBlock.Settings.create().mapColor(apricorn.mapColor()).ticksRandomly().strength(Blocks.OAK_LOG.hardness, Blocks.OAK_LOG.blastResistance).sounds(BlockSoundGroup.WOOD).nonOpaque(), apricorn))
|
||||||
|
|
||||||
private fun tumblestoneBlock(name: String, stage: Int, height: Int, xzOffset: Int, nextStage: Block?) : Block {
|
private fun tumblestoneBlock(name: String, stage: Int, height: Int, xzOffset: Int, nextStage: Block?) : Block {
|
||||||
return this.create(name, TumblestoneBlock(BlockBehaviour.Properties.of()
|
return this.create(name, TumblestoneBlock(AbstractBlock.Settings.create()
|
||||||
.pushReaction(PushReaction.DESTROY)
|
.pistonBehavior(PistonBehavior.DESTROY)
|
||||||
.noOcclusion()
|
.nonOpaque()
|
||||||
.strength(1.5F)
|
.strength(1.5F)
|
||||||
.sound(CobblemonSounds.TUMBLESTONE_SOUNDS),
|
.sounds(CobblemonSounds.TUMBLESTONE_SOUNDS),
|
||||||
stage, height, xzOffset, nextStage))
|
stage, height, xzOffset, nextStage))
|
||||||
}
|
}
|
||||||
|
|
||||||
private val berries = mutableMapOf<ResourceLocation, BerryBlock>()
|
private val berries = mutableMapOf<Identifier, BerryBlock>()
|
||||||
|
|
||||||
val AGUAV_BERRY = this.berryBlock("aguav")
|
val AGUAV_BERRY = this.berryBlock("aguav")
|
||||||
val APICOT_BERRY = this.berryBlock("apicot")
|
val APICOT_BERRY = this.berryBlock("apicot")
|
||||||
@@ -476,7 +528,6 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
|||||||
val WEPEAR_BERRY = this.berryBlock("wepear")
|
val WEPEAR_BERRY = this.berryBlock("wepear")
|
||||||
val WIKI_BERRY = this.berryBlock("wiki")
|
val WIKI_BERRY = this.berryBlock("wiki")
|
||||||
val YACHE_BERRY = this.berryBlock("yache")
|
val YACHE_BERRY = this.berryBlock("yache")
|
||||||
//val BINDING_SOIL = this.create("binding_soil", BindingSoilBlock(BlockBehaviour.Properties.of()))
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
/**
|
/**
|
||||||
@@ -501,7 +552,7 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
|||||||
|
|
||||||
private fun berryBlock(name: String): BerryBlock {
|
private fun berryBlock(name: String): BerryBlock {
|
||||||
val identifier = cobblemonResource("${name}_berry")
|
val identifier = cobblemonResource("${name}_berry")
|
||||||
val block = this.create(identifier.path, BerryBlock(identifier, BlockBehaviour.Properties.ofFullCopy(Blocks.WHEAT).dynamicShape().sound(CobblemonSounds.BERRY_BUSH_SOUNDS).strength(0.2F)))
|
val block = this.create(identifier.path, BerryBlock(identifier, AbstractBlock.Settings.copy(Blocks.WHEAT).dynamicBounds().sounds(CobblemonSounds.BERRY_BUSH_SOUNDS).strength(0.2F)))
|
||||||
this.berries[identifier] = block
|
this.berries[identifier] = block
|
||||||
return block
|
return block
|
||||||
}
|
}
|
||||||
@@ -509,7 +560,7 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
|||||||
/**
|
/**
|
||||||
* Calls helper method from Vanilla
|
* Calls helper method from Vanilla
|
||||||
*/
|
*/
|
||||||
private fun log(name: String, arg: MapColor = MapColor.DIRT, arg2: MapColor = MapColor.DIRT): Block {
|
private fun log(name: String, arg: MapColor = MapColor.DIRT_BROWN, arg2: MapColor = MapColor.DIRT_BROWN): PillarBlock {
|
||||||
val block = BlocksInvoker.createLogBlock(arg, arg2)
|
val block = BlocksInvoker.createLogBlock(arg, arg2)
|
||||||
return this.create(name, block)
|
return this.create(name, block)
|
||||||
}
|
}
|
||||||
@@ -529,16 +580,16 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
|||||||
return block
|
return block
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun evolutionStoneOre(name: String) = this.create(name, DropExperienceBlock(UniformInt.of(1, 2), BlockBehaviour.Properties.ofFullCopy(Blocks.IRON_ORE)))
|
private fun evolutionStoneOre(name: String) = this.create(name, ExperienceDroppingBlock(AbstractBlock.Settings.copy(Blocks.IRON_ORE), UniformIntProvider.create(1, 2)))
|
||||||
|
|
||||||
private fun deepslateEvolutionStoneOre(name: String) = this.create(name, DropExperienceBlock(UniformInt.of(1, 2), BlockBehaviour.Properties.ofFullCopy(Blocks.DEEPSLATE_IRON_ORE)))
|
private fun deepslateEvolutionStoneOre(name: String) = this.create(name, ExperienceDroppingBlock(AbstractBlock.Settings.copy(Blocks.DEEPSLATE_IRON_ORE), UniformIntProvider.create(1, 2)))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method for creating leaves
|
* Helper method for creating leaves
|
||||||
* copied over from Vanilla
|
* copied over from Vanilla
|
||||||
*/
|
*/
|
||||||
private fun leaves(name: String): Block {
|
private fun leaves(name: String): LeavesBlock {
|
||||||
val block = BlocksInvoker.createLeavesBlock(SoundType.GRASS)
|
val block = BlocksInvoker.createLeavesBlock(BlockSoundGroup.GRASS)
|
||||||
return this.create(name, block)
|
return this.create(name, block)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common
|
|
||||||
|
|
||||||
import com.bedrockk.molang.Expression
|
|
||||||
import com.cobblemon.mod.common.api.ai.config.BrainConfig
|
|
||||||
import com.cobblemon.mod.common.api.ai.config.task.TaskConfig
|
|
||||||
import com.cobblemon.mod.common.api.data.DataRegistry
|
|
||||||
import com.cobblemon.mod.common.api.data.JsonDataRegistry
|
|
||||||
import com.cobblemon.mod.common.api.molang.ExpressionLike
|
|
||||||
import com.cobblemon.mod.common.api.reactive.SimpleObservable
|
|
||||||
import com.cobblemon.mod.common.util.adapters.ActivityAdapter
|
|
||||||
import com.cobblemon.mod.common.util.adapters.BrainConfigAdapter
|
|
||||||
import com.cobblemon.mod.common.util.adapters.ExpressionAdapter
|
|
||||||
import com.cobblemon.mod.common.util.adapters.ExpressionLikeAdapter
|
|
||||||
import com.cobblemon.mod.common.util.adapters.TaskConfigAdapter
|
|
||||||
import com.cobblemon.mod.common.util.cobblemonResource
|
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.google.gson.GsonBuilder
|
|
||||||
import com.google.gson.reflect.TypeToken
|
|
||||||
import net.minecraft.resources.ResourceLocation
|
|
||||||
import net.minecraft.server.level.ServerPlayer
|
|
||||||
import net.minecraft.server.packs.PackType
|
|
||||||
import net.minecraft.world.entity.schedule.Activity
|
|
||||||
|
|
||||||
object CobblemonBrainConfigs : JsonDataRegistry<List<BrainConfig>> {
|
|
||||||
override val gson: Gson = GsonBuilder()
|
|
||||||
.setPrettyPrinting()
|
|
||||||
.registerTypeAdapter(Activity::class.java, ActivityAdapter)
|
|
||||||
.registerTypeAdapter(Expression::class.java, ExpressionAdapter)
|
|
||||||
.registerTypeAdapter(ExpressionLike::class.java, ExpressionLikeAdapter)
|
|
||||||
.registerTypeAdapter(BrainConfig::class.java, BrainConfigAdapter)
|
|
||||||
.registerTypeAdapter(TaskConfig::class.java, TaskConfigAdapter)
|
|
||||||
.create()
|
|
||||||
|
|
||||||
override val typeToken = TypeToken.getParameterized(List::class.java, BrainConfig::class.java) as TypeToken<List<BrainConfig>>
|
|
||||||
override val resourcePath = "brain_presets"
|
|
||||||
override val id: ResourceLocation = cobblemonResource("brain_presets")
|
|
||||||
override val type = PackType.SERVER_DATA
|
|
||||||
override val observable = SimpleObservable<CobblemonBrainConfigs>()
|
|
||||||
|
|
||||||
val presets = mutableMapOf<ResourceLocation, List<BrainConfig>>()
|
|
||||||
|
|
||||||
override fun sync(player: ServerPlayer) {
|
|
||||||
// TODO implement probs ay
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun reload(data: Map<ResourceLocation, List<BrainConfig>>) {
|
|
||||||
presets.clear()
|
|
||||||
presets.putAll(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,39 +8,39 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common
|
package com.cobblemon.mod.common
|
||||||
|
|
||||||
|
import net.minecraft.block.Block
|
||||||
|
import net.minecraft.block.entity.BlockEntity
|
||||||
|
import net.minecraft.block.entity.BlockEntityType
|
||||||
|
import net.minecraft.client.color.block.BlockColorProvider
|
||||||
|
import net.minecraft.client.color.item.ItemColorProvider
|
||||||
|
import net.minecraft.client.model.TexturedModelData
|
||||||
|
import net.minecraft.client.particle.ParticleFactory
|
||||||
|
import net.minecraft.client.particle.SpriteProvider
|
||||||
|
import net.minecraft.client.render.RenderLayer
|
||||||
|
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory
|
||||||
|
import net.minecraft.client.render.entity.EntityRendererFactory
|
||||||
|
import net.minecraft.client.render.entity.model.EntityModelLayer
|
||||||
|
import net.minecraft.entity.Entity
|
||||||
|
import net.minecraft.entity.EntityType
|
||||||
|
import net.minecraft.item.Item
|
||||||
|
import net.minecraft.particle.ParticleEffect
|
||||||
|
import net.minecraft.particle.ParticleType
|
||||||
import java.util.function.Supplier
|
import java.util.function.Supplier
|
||||||
import net.minecraft.client.color.block.BlockColor
|
|
||||||
import net.minecraft.client.color.item.ItemColor
|
|
||||||
import net.minecraft.client.model.geom.ModelLayerLocation
|
|
||||||
import net.minecraft.client.model.geom.builders.LayerDefinition
|
|
||||||
import net.minecraft.client.particle.ParticleProvider
|
|
||||||
import net.minecraft.client.particle.SpriteSet
|
|
||||||
import net.minecraft.client.renderer.RenderType
|
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
|
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererProvider
|
|
||||||
import net.minecraft.core.particles.ParticleOptions
|
|
||||||
import net.minecraft.core.particles.ParticleType
|
|
||||||
import net.minecraft.world.entity.Entity
|
|
||||||
import net.minecraft.world.entity.EntityType
|
|
||||||
import net.minecraft.world.item.Item
|
|
||||||
import net.minecraft.world.level.block.Block
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
|
||||||
|
|
||||||
interface CobblemonClientImplementation {
|
interface CobblemonClientImplementation {
|
||||||
fun registerLayer(modelLayer: ModelLayerLocation, supplier: Supplier<LayerDefinition>)
|
fun registerLayer(modelLayer: EntityModelLayer, supplier: Supplier<TexturedModelData>)
|
||||||
fun <T : ParticleOptions> registerParticleFactory(
|
fun <T : ParticleEffect> registerParticleFactory(
|
||||||
type: ParticleType<T>,
|
type: ParticleType<T>,
|
||||||
factory: (SpriteSet) -> ParticleProvider<T>
|
factory: (SpriteProvider) -> ParticleFactory<T>
|
||||||
)
|
)
|
||||||
|
|
||||||
fun registerBlockRenderType(layer: RenderType, vararg blocks: Block)
|
fun registerBlockRenderType(layer: RenderLayer, vararg blocks: Block)
|
||||||
|
|
||||||
fun registerItemColors(provider: ItemColor, vararg items: Item)
|
fun registerItemColors(provider: ItemColorProvider, vararg items: Item)
|
||||||
|
|
||||||
fun registerBlockColors(provider: BlockColor, vararg blocks: Block)
|
fun registerBlockColors(provider: BlockColorProvider, vararg blocks: Block)
|
||||||
|
|
||||||
fun <T : BlockEntity> registerBlockEntityRenderer(type: BlockEntityType<out T>, factory: BlockEntityRendererProvider<T>)
|
fun <T : BlockEntity> registerBlockEntityRenderer(type: BlockEntityType<out T>, factory: BlockEntityRendererFactory<T>)
|
||||||
|
|
||||||
fun <T : Entity> registerEntityRenderer(type: EntityType<out T>, factory: EntityRendererProvider<T>)
|
fun <T : Entity> registerEntityRenderer(type: EntityType<out T>, factory: EntityRendererFactory<T>)
|
||||||
}
|
}
|
||||||
@@ -10,17 +10,15 @@ package com.cobblemon.mod.common
|
|||||||
|
|
||||||
import com.cobblemon.mod.common.command.*
|
import com.cobblemon.mod.common.command.*
|
||||||
import com.mojang.brigadier.CommandDispatcher
|
import com.mojang.brigadier.CommandDispatcher
|
||||||
import net.minecraft.commands.CommandBuildContext
|
import net.minecraft.command.CommandRegistryAccess
|
||||||
import net.minecraft.commands.CommandSourceStack
|
import net.minecraft.server.command.CommandManager
|
||||||
import net.minecraft.commands.Commands
|
import net.minecraft.server.command.ServerCommandSource
|
||||||
|
|
||||||
object CobblemonCommands {
|
object CobblemonCommands {
|
||||||
fun register(dispatcher: CommandDispatcher<CommandSourceStack>, registry: CommandBuildContext, selection: Commands.CommandSelection) {
|
fun register(dispatcher: CommandDispatcher<ServerCommandSource>, registry: CommandRegistryAccess, selection: CommandManager.RegistrationEnvironment) {
|
||||||
SpawnPokemon.register(dispatcher)
|
SpawnPokemon.register(dispatcher)
|
||||||
SpawnNPCCommand.register(dispatcher)
|
|
||||||
GivePokemon.register(dispatcher)
|
GivePokemon.register(dispatcher)
|
||||||
TakePokemon.register(dispatcher)
|
TakePokemon.register(dispatcher)
|
||||||
ChangeEyeHeight.register(dispatcher)
|
|
||||||
ChangeScaleAndSize.register(dispatcher)
|
ChangeScaleAndSize.register(dispatcher)
|
||||||
ChangeWalkSpeed.register(dispatcher)
|
ChangeWalkSpeed.register(dispatcher)
|
||||||
TestCommand.register(dispatcher)
|
TestCommand.register(dispatcher)
|
||||||
@@ -41,7 +39,6 @@ object CobblemonCommands {
|
|||||||
PcCommand.register(dispatcher)
|
PcCommand.register(dispatcher)
|
||||||
SpawnPokemonFromPool.register(dispatcher)
|
SpawnPokemonFromPool.register(dispatcher)
|
||||||
PokeboxCommand.register(dispatcher)
|
PokeboxCommand.register(dispatcher)
|
||||||
PokedexCommand.register(dispatcher)
|
|
||||||
TestStoreCommand.register(dispatcher)
|
TestStoreCommand.register(dispatcher)
|
||||||
QueryLearnsetCommand.register(dispatcher)
|
QueryLearnsetCommand.register(dispatcher)
|
||||||
TestPcSlotCommand.register(dispatcher)
|
TestPcSlotCommand.register(dispatcher)
|
||||||
@@ -51,12 +48,6 @@ object CobblemonCommands {
|
|||||||
PokemonRestartCommand.register(dispatcher)
|
PokemonRestartCommand.register(dispatcher)
|
||||||
BedrockParticleCommand.register(dispatcher)
|
BedrockParticleCommand.register(dispatcher)
|
||||||
OpenDialogueCommand.register(dispatcher)
|
OpenDialogueCommand.register(dispatcher)
|
||||||
NPCEditCommand.register(dispatcher)
|
|
||||||
NPCDeleteCommand.register(dispatcher)
|
|
||||||
AbandonMultiTeam.register(dispatcher)
|
|
||||||
FreezePokemonCommand.register(dispatcher)
|
|
||||||
ApplyPlayerTextureCommand.register(dispatcher)
|
|
||||||
RunMolangScriptCommand.register(dispatcher)
|
|
||||||
|
|
||||||
// Possibly lock down registration if and only if under dev environment or running in an environment
|
// Possibly lock down registration if and only if under dev environment or running in an environment
|
||||||
// with a certain system environment variable set
|
// with a certain system environment variable set
|
||||||
|
|||||||
@@ -11,34 +11,31 @@ package com.cobblemon.mod.common
|
|||||||
import com.cobblemon.mod.common.api.pokeball.PokeBalls
|
import com.cobblemon.mod.common.api.pokeball.PokeBalls
|
||||||
import com.cobblemon.mod.common.entity.boat.CobblemonBoatEntity
|
import com.cobblemon.mod.common.entity.boat.CobblemonBoatEntity
|
||||||
import com.cobblemon.mod.common.entity.boat.CobblemonChestBoatEntity
|
import com.cobblemon.mod.common.entity.boat.CobblemonChestBoatEntity
|
||||||
import com.cobblemon.mod.common.entity.fishing.PokeRodFishingBobberEntity
|
|
||||||
import com.cobblemon.mod.common.entity.generic.GenericBedrockEntity
|
import com.cobblemon.mod.common.entity.generic.GenericBedrockEntity
|
||||||
import com.cobblemon.mod.common.entity.npc.NPCEntity
|
|
||||||
import com.cobblemon.mod.common.entity.pokeball.EmptyPokeBallEntity
|
import com.cobblemon.mod.common.entity.pokeball.EmptyPokeBallEntity
|
||||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||||
import com.cobblemon.mod.common.platform.PlatformRegistry
|
import com.cobblemon.mod.common.platform.PlatformRegistry
|
||||||
import com.cobblemon.mod.common.util.cobblemonResource
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
import net.minecraft.core.Registry
|
import net.minecraft.entity.EntityType
|
||||||
import net.minecraft.core.registries.BuiltInRegistries
|
import net.minecraft.entity.LivingEntity
|
||||||
import net.minecraft.core.registries.Registries
|
import net.minecraft.entity.SpawnGroup
|
||||||
import net.minecraft.world.entity.EntityType
|
import net.minecraft.entity.attribute.DefaultAttributeContainer
|
||||||
import net.minecraft.world.entity.LivingEntity
|
import net.minecraft.registry.Registries
|
||||||
import net.minecraft.resources.ResourceKey
|
import net.minecraft.registry.Registry
|
||||||
import net.minecraft.world.entity.MobCategory
|
import net.minecraft.registry.RegistryKey
|
||||||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier
|
import net.minecraft.registry.RegistryKeys
|
||||||
|
|
||||||
object CobblemonEntities : PlatformRegistry<Registry<EntityType<*>>, ResourceKey<Registry<EntityType<*>>>, EntityType<*>>() {
|
object CobblemonEntities : PlatformRegistry<Registry<EntityType<*>>, RegistryKey<Registry<EntityType<*>>>, EntityType<*>>() {
|
||||||
|
|
||||||
|
|
||||||
override val registry: Registry<EntityType<*>> = BuiltInRegistries.ENTITY_TYPE
|
override val registry: Registry<EntityType<*>> = Registries.ENTITY_TYPE
|
||||||
override val resourceKey: ResourceKey<Registry<EntityType<*>>> = Registries.ENTITY_TYPE
|
override val registryKey: RegistryKey<Registry<EntityType<*>>> = RegistryKeys.ENTITY_TYPE
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val POKEMON_KEY = cobblemonResource("pokemon")
|
val POKEMON_KEY = cobblemonResource("pokemon")
|
||||||
@JvmField
|
@JvmField
|
||||||
val POKEMON: EntityType<PokemonEntity> = this.create(
|
val POKEMON: EntityType<PokemonEntity> = this.create(
|
||||||
POKEMON_KEY.path,
|
POKEMON_KEY.path,
|
||||||
EntityType.Builder.of({ _, world -> PokemonEntity(world) }, MobCategory.CREATURE)
|
EntityType.Builder.create({ _, world -> PokemonEntity(world) }, SpawnGroup.CREATURE)
|
||||||
.build(POKEMON_KEY.toString())
|
.build(POKEMON_KEY.toString())
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -47,7 +44,7 @@ object CobblemonEntities : PlatformRegistry<Registry<EntityType<*>>, ResourceKey
|
|||||||
@JvmField
|
@JvmField
|
||||||
val EMPTY_POKEBALL: EntityType<EmptyPokeBallEntity> = this.create(
|
val EMPTY_POKEBALL: EntityType<EmptyPokeBallEntity> = this.create(
|
||||||
EMPTY_POKEBALL_KEY.path,
|
EMPTY_POKEBALL_KEY.path,
|
||||||
EntityType.Builder.of({ _, world -> EmptyPokeBallEntity(PokeBalls.POKE_BALL, world) }, MobCategory.MISC)
|
EntityType.Builder.create({ _, world -> EmptyPokeBallEntity(PokeBalls.POKE_BALL, world) }, SpawnGroup.MISC)
|
||||||
.build(EMPTY_POKEBALL_KEY.toString())
|
.build(EMPTY_POKEBALL_KEY.toString())
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -56,7 +53,7 @@ object CobblemonEntities : PlatformRegistry<Registry<EntityType<*>>, ResourceKey
|
|||||||
@JvmField
|
@JvmField
|
||||||
val BOAT: EntityType<CobblemonBoatEntity> = this.create(
|
val BOAT: EntityType<CobblemonBoatEntity> = this.create(
|
||||||
BOAT_KEY.path,
|
BOAT_KEY.path,
|
||||||
EntityType.Builder.of(::CobblemonBoatEntity, MobCategory.MISC).sized(1.375F, 0.5625F).clientTrackingRange(10)
|
EntityType.Builder.create(::CobblemonBoatEntity, SpawnGroup.MISC).setDimensions(1.375F, 0.5625F).maxTrackingRange(10)
|
||||||
.build(BOAT_KEY.toString())
|
.build(BOAT_KEY.toString())
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -65,38 +62,21 @@ object CobblemonEntities : PlatformRegistry<Registry<EntityType<*>>, ResourceKey
|
|||||||
@JvmField
|
@JvmField
|
||||||
val CHEST_BOAT: EntityType<CobblemonChestBoatEntity> = this.create(
|
val CHEST_BOAT: EntityType<CobblemonChestBoatEntity> = this.create(
|
||||||
CHEST_BOAT_KEY.path,
|
CHEST_BOAT_KEY.path,
|
||||||
EntityType.Builder.of(::CobblemonChestBoatEntity, MobCategory.MISC).sized(1.375F, 0.5625F).clientTrackingRange(10)
|
EntityType.Builder.create(::CobblemonChestBoatEntity, SpawnGroup.MISC).setDimensions(1.375F, 0.5625F).maxTrackingRange(10)
|
||||||
.build(CHEST_BOAT_KEY.toString())
|
.build(CHEST_BOAT_KEY.toString())
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val POKE_BOBBER_KEY = cobblemonResource("poke_bobber")
|
|
||||||
@JvmField
|
|
||||||
val POKE_BOBBER: EntityType<PokeRodFishingBobberEntity> = this.create(
|
|
||||||
POKE_BOBBER_KEY.path,
|
|
||||||
EntityType.Builder.of(::PokeRodFishingBobberEntity, MobCategory.MISC).sized(0.5F, 0.5F).clientTrackingRange(10)
|
|
||||||
.build(POKE_BOBBER_KEY.toString())
|
|
||||||
)
|
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val GENERIC_BEDROCK_ENTITY_KEY = cobblemonResource("generic_bedrock")
|
val GENERIC_BEDROCK_ENTITY_KEY = cobblemonResource("generic_bedrock")
|
||||||
@JvmField
|
@JvmField
|
||||||
val GENERIC_BEDROCK_ENTITY: EntityType<GenericBedrockEntity> = this.create(
|
val GENERIC_BEDROCK_ENTITY: EntityType<GenericBedrockEntity> = this.create(
|
||||||
GENERIC_BEDROCK_ENTITY_KEY.path,
|
GENERIC_BEDROCK_ENTITY_KEY.path,
|
||||||
EntityType.Builder.of({ _, world -> GenericBedrockEntity(world) }, MobCategory.MISC)
|
EntityType.Builder.create({ _, world -> GenericBedrockEntity(world) }, SpawnGroup.MISC)
|
||||||
.build(GENERIC_BEDROCK_ENTITY_KEY.toString())
|
.build(GENERIC_BEDROCK_ENTITY_KEY.toString())
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmField
|
fun registerAttributes(consumer: (EntityType<out LivingEntity>, DefaultAttributeContainer.Builder) -> Unit) {
|
||||||
val NPC_KEY = cobblemonResource("npc")
|
|
||||||
@JvmField
|
|
||||||
val NPC: EntityType<NPCEntity> = create(
|
|
||||||
NPC_KEY.path,
|
|
||||||
EntityType.Builder.of({ _, world -> NPCEntity(world) }, MobCategory.CREATURE).build("$NPC_KEY")
|
|
||||||
)
|
|
||||||
|
|
||||||
fun registerAttributes(consumer: (EntityType<out LivingEntity>, AttributeSupplier.Builder) -> Unit) {
|
|
||||||
consumer(POKEMON, PokemonEntity.createAttributes())
|
consumer(POKEMON, PokemonEntity.createAttributes())
|
||||||
consumer(NPC, NPCEntity.createAttributes())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common
|
|
||||||
|
|
||||||
import com.bedrockk.molang.runtime.MoLangRuntime
|
|
||||||
import com.bedrockk.molang.runtime.value.MoValue
|
|
||||||
import com.cobblemon.mod.common.CobblemonNetwork.sendPacket
|
|
||||||
import com.cobblemon.mod.common.api.data.DataRegistry
|
|
||||||
import com.cobblemon.mod.common.api.events.Cancelable
|
|
||||||
import com.cobblemon.mod.common.api.molang.ExpressionLike
|
|
||||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.setup
|
|
||||||
import com.cobblemon.mod.common.api.reactive.SimpleObservable
|
|
||||||
import com.cobblemon.mod.common.api.scripting.CobblemonScripts
|
|
||||||
import com.cobblemon.mod.common.net.messages.client.data.FlowRegistrySyncPacket
|
|
||||||
import com.cobblemon.mod.common.util.asExpressionLike
|
|
||||||
import com.cobblemon.mod.common.util.cobblemonResource
|
|
||||||
import com.cobblemon.mod.common.util.endsWith
|
|
||||||
import java.util.concurrent.ExecutionException
|
|
||||||
import net.minecraft.resources.ResourceLocation
|
|
||||||
import net.minecraft.server.level.ServerPlayer
|
|
||||||
import net.minecraft.server.packs.PackType
|
|
||||||
import net.minecraft.server.packs.resources.ResourceManager
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Holds all the flows that are loaded from the server's data packs. A flow is foldered under the event identifier,
|
|
||||||
* which can be Cobblemon's namespace but can also be minecraft or any other namespace someone has added hooks for.
|
|
||||||
* The value of the map is a list of MoLang scripts that will execute when that event occurs.
|
|
||||||
*
|
|
||||||
* @author Hiroku
|
|
||||||
* @since February 24th, 2024
|
|
||||||
*/
|
|
||||||
object CobblemonFlows : DataRegistry {
|
|
||||||
override val id = cobblemonResource("flows")
|
|
||||||
override val observable = SimpleObservable<CobblemonFlows>()
|
|
||||||
override val type = PackType.SERVER_DATA
|
|
||||||
override fun sync(player: ServerPlayer) {
|
|
||||||
player.sendPacket(FlowRegistrySyncPacket(clientFlows.entries))
|
|
||||||
}
|
|
||||||
|
|
||||||
val runtime by lazy { MoLangRuntime().setup() } // Lazy for if someone adds to generalFunctions in MoLangFunctions
|
|
||||||
|
|
||||||
val clientFlows = hashMapOf<ResourceLocation, MutableList<ExpressionLike>>()
|
|
||||||
val flows = hashMapOf<ResourceLocation, MutableList<ExpressionLike>>()
|
|
||||||
|
|
||||||
override fun reload(manager: ResourceManager) {
|
|
||||||
clientFlows.clear()
|
|
||||||
flows.clear()
|
|
||||||
|
|
||||||
val unsortedFlows = mutableMapOf<ResourceLocation, MutableList<Pair<String, ExpressionLike>>>()
|
|
||||||
val folderBeforeNameRegex = ".*\\/([^\\/]+)\\/[^\\/]+\$".toRegex()
|
|
||||||
manager.listResources("flows") { path -> path.endsWith(CobblemonScripts.MOLANG_EXTENSION) }.forEach { (identifier, resource) ->
|
|
||||||
resource.openAsReader().use { stream ->
|
|
||||||
stream.buffered().use { reader ->
|
|
||||||
try {
|
|
||||||
val expression = reader.readText().asExpressionLike()
|
|
||||||
|
|
||||||
val event = folderBeforeNameRegex.find(identifier.path)?.groupValues?.get(1)
|
|
||||||
?: throw IllegalArgumentException("Invalid flow path: $identifier. Should have a folder structure that includes the name of the event being flowed.")
|
|
||||||
|
|
||||||
val flowKey = ResourceLocation.fromNamespaceAndPath(identifier.namespace, event)
|
|
||||||
unsortedFlows.putIfAbsent(flowKey, mutableListOf())
|
|
||||||
unsortedFlows[flowKey]!!.add(identifier.path to expression)
|
|
||||||
} catch (exception: Exception) {
|
|
||||||
throw ExecutionException("Error loading MoLang script for flow: $identifier", exception)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsortedFlows.forEach { (key, value) ->
|
|
||||||
value.sortBy { it.first }
|
|
||||||
if (key.path.startsWith("flows/client/")) {
|
|
||||||
clientFlows.getOrPut(key) { mutableListOf() }.addAll(value.map { it.second })
|
|
||||||
} else {
|
|
||||||
flows.getOrPut(key) { mutableListOf() }.addAll(value.map { it.second })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Cobblemon.LOGGER.info("Loaded ${flows.size} flows and ${clientFlows.size} client flows")
|
|
||||||
observable.emit(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun run(eventResourceLocation: ResourceLocation, context: Map<String, MoValue>, cancelable: Cancelable? = null) {
|
|
||||||
if (cancelable == null) {
|
|
||||||
runtime.environment.query.functions.remove("cancel")
|
|
||||||
} else {
|
|
||||||
runtime.environment.query.addFunction("cancel") { cancelable }
|
|
||||||
}
|
|
||||||
|
|
||||||
flows[eventResourceLocation]?.forEach {
|
|
||||||
if (cancelable != null && cancelable.isCanceled) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
it.resolve(runtime, context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,22 +8,32 @@
|
|||||||
|
|
||||||
package com.cobblemon.mod.common
|
package com.cobblemon.mod.common
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.api.data.JsonDataRegistry
|
||||||
|
import com.cobblemon.mod.common.api.net.ClientNetworkPacketHandler
|
||||||
import com.cobblemon.mod.common.api.net.NetworkPacket
|
import com.cobblemon.mod.common.api.net.NetworkPacket
|
||||||
|
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
|
||||||
import com.mojang.brigadier.arguments.ArgumentType
|
import com.mojang.brigadier.arguments.ArgumentType
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
import net.minecraft.commands.synchronization.ArgumentTypeInfo
|
import net.minecraft.advancement.criterion.Criterion
|
||||||
import net.minecraft.resources.ResourceKey
|
import net.minecraft.block.ComposterBlock
|
||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.command.argument.serialize.ArgumentSerializer
|
||||||
|
import net.minecraft.item.ItemConvertible
|
||||||
|
import net.minecraft.network.PacketByteBuf
|
||||||
|
import net.minecraft.network.listener.ClientPlayPacketListener
|
||||||
|
import net.minecraft.network.packet.Packet
|
||||||
|
import net.minecraft.registry.RegistryKey
|
||||||
|
import net.minecraft.registry.tag.TagKey
|
||||||
|
import net.minecraft.resource.ResourceManager
|
||||||
|
import net.minecraft.resource.ResourceReloader
|
||||||
|
import net.minecraft.resource.ResourceType
|
||||||
import net.minecraft.server.MinecraftServer
|
import net.minecraft.server.MinecraftServer
|
||||||
import net.minecraft.server.level.ServerPlayer
|
import net.minecraft.server.network.ServerPlayerEntity
|
||||||
import net.minecraft.server.packs.PackType
|
import net.minecraft.text.Text
|
||||||
import net.minecraft.server.packs.resources.PreparableReloadListener
|
import net.minecraft.util.Identifier
|
||||||
import net.minecraft.tags.TagKey
|
import net.minecraft.world.GameRules
|
||||||
import net.minecraft.world.level.GameRules
|
import net.minecraft.world.biome.Biome
|
||||||
import net.minecraft.world.level.ItemLike
|
import net.minecraft.world.gen.GenerationStep
|
||||||
import net.minecraft.world.level.biome.Biome
|
import net.minecraft.world.gen.feature.PlacedFeature
|
||||||
import net.minecraft.world.level.levelgen.GenerationStep
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature
|
|
||||||
|
|
||||||
interface CobblemonImplementation {
|
interface CobblemonImplementation {
|
||||||
val modAPI: ModAPI
|
val modAPI: ModAPI
|
||||||
@@ -60,10 +70,6 @@ interface CobblemonImplementation {
|
|||||||
*/
|
*/
|
||||||
fun registerSoundEvents()
|
fun registerSoundEvents()
|
||||||
|
|
||||||
fun registerDataComponents()
|
|
||||||
|
|
||||||
fun registerEntityDataSerializers()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
*
|
*
|
||||||
@@ -94,12 +100,6 @@ interface CobblemonImplementation {
|
|||||||
*/
|
*/
|
||||||
fun registerBlockEntityTypes()
|
fun registerBlockEntityTypes()
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
fun registerVillagers()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
*
|
*
|
||||||
@@ -108,9 +108,6 @@ interface CobblemonImplementation {
|
|||||||
|
|
||||||
fun registerParticles()
|
fun registerParticles()
|
||||||
|
|
||||||
fun registerEntitySubPredicates()
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a feature to the current platform implementation.
|
* Add a feature to the current platform implementation.
|
||||||
*
|
*
|
||||||
@@ -118,7 +115,7 @@ interface CobblemonImplementation {
|
|||||||
* @param step The [GenerationStep.Feature] of this feature.
|
* @param step The [GenerationStep.Feature] of this feature.
|
||||||
* @param validTag The [TagKey] required by the [Biome] for this feature to generate in, if null all biomes are valid.
|
* @param validTag The [TagKey] required by the [Biome] for this feature to generate in, if null all biomes are valid.
|
||||||
*/
|
*/
|
||||||
fun addFeatureToWorldGen(feature: ResourceKey<PlacedFeature>, step: GenerationStep.Decoration, validTag: TagKey<Biome>?)
|
fun addFeatureToWorldGen(feature: RegistryKey<PlacedFeature>, step: GenerationStep.Feature, validTag: TagKey<Biome>?)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
@@ -129,7 +126,7 @@ interface CobblemonImplementation {
|
|||||||
* @param argumentClass
|
* @param argumentClass
|
||||||
* @param serializer
|
* @param serializer
|
||||||
*/
|
*/
|
||||||
fun <A : ArgumentType<*>, T : ArgumentTypeInfo.Template<A>> registerCommandArgument(identifier: ResourceLocation, argumentClass: KClass<A>, serializer: ArgumentTypeInfo<A, T>)
|
fun <A : ArgumentType<*>, T : ArgumentSerializer.ArgumentTypeProperties<A>> registerCommandArgument(identifier: Identifier, argumentClass: KClass<A>, serializer: ArgumentSerializer<A, T>)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
@@ -140,7 +137,7 @@ interface CobblemonImplementation {
|
|||||||
* @param type
|
* @param type
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
fun <T : GameRules.Value<T>> registerGameRule(name: String, category: GameRules.Category, type: GameRules.Type<T>): GameRules.Key<T>
|
fun <T : GameRules.Rule<T>> registerGameRule(name: String, category: GameRules.Category, type: GameRules.Type<T>): GameRules.Key<T>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
@@ -149,7 +146,7 @@ interface CobblemonImplementation {
|
|||||||
* @param criteria
|
* @param criteria
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
fun registerCriteria()
|
fun <T : Criterion<*>> registerCriteria(criteria: T): T
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
@@ -159,7 +156,7 @@ interface CobblemonImplementation {
|
|||||||
* @param type
|
* @param type
|
||||||
* @param dependencies
|
* @param dependencies
|
||||||
*/
|
*/
|
||||||
fun registerResourceReloader(identifier: ResourceLocation, reloader: PreparableReloadListener, type: PackType, dependencies: Collection<ResourceLocation>)
|
fun registerResourceReloader(identifier: Identifier, reloader: ResourceReloader, type: ResourceType, dependencies: Collection<Identifier>)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
@@ -168,13 +165,31 @@ interface CobblemonImplementation {
|
|||||||
*/
|
*/
|
||||||
fun server(): MinecraftServer?
|
fun server(): MinecraftServer?
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles platform independent reloading of a [JsonDataRegistry].
|
||||||
|
*
|
||||||
|
* @param registry The [JsonDataRegistry] to reload.
|
||||||
|
* @param manager The [ResourceManager] to reload from.
|
||||||
|
*/
|
||||||
|
fun <T> reloadJsonRegistry(registry: JsonDataRegistry<T>, manager: ResourceManager): HashMap<Identifier, T>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an item to the [ComposterBlock].
|
* Registers an item to the [ComposterBlock].
|
||||||
*
|
*
|
||||||
* @param item The [ItemLike] being registered.
|
* @param item The [ItemConvertible] being registered.
|
||||||
* @param chance The chance % of increasing the composter level, 0 to 1 expected.
|
* @param chance The chance % of increasing the composter level, 0 to 1 expected.
|
||||||
*/
|
*/
|
||||||
fun registerCompostable(item: ItemLike, chance: Float)
|
fun registerCompostable(item: ItemConvertible, chance: Float)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a builtin resource pack.
|
||||||
|
*
|
||||||
|
* @param id The unique [Identifier] of this pack.
|
||||||
|
* @param title The title displayed in the resource pack GUI, the description is still a part of the pack metadata.
|
||||||
|
* @param activationBehaviour The [ResourcePackActivationBehaviour] for this pack.
|
||||||
|
*/
|
||||||
|
fun registerBuiltinResourcePack(id: Identifier, title: Text, activationBehaviour: ResourcePackActivationBehaviour)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class ResourcePackActivationBehaviour {
|
enum class ResourcePackActivationBehaviour {
|
||||||
@@ -199,17 +214,30 @@ enum class ResourcePackActivationBehaviour {
|
|||||||
|
|
||||||
enum class ModAPI {
|
enum class ModAPI {
|
||||||
FABRIC,
|
FABRIC,
|
||||||
FORGE,
|
FORGE
|
||||||
NEOFORGE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NetworkManager {
|
interface NetworkManager {
|
||||||
fun sendPacketToPlayer(player: ServerPlayer, packet: NetworkPacket<*>)
|
|
||||||
|
|
||||||
fun sendToServer(packet: NetworkPacket<*>)
|
fun registerClientBound()
|
||||||
|
|
||||||
|
fun registerServerBound()
|
||||||
|
|
||||||
|
fun <T: NetworkPacket<T>> createClientBound(identifier: Identifier, kClass: KClass<T>, encoder: (T, PacketByteBuf) -> Unit, decoder: (PacketByteBuf) -> T, handler: ClientNetworkPacketHandler<T>)
|
||||||
|
|
||||||
|
fun <T: NetworkPacket<T>> createServerBound(identifier: Identifier, kClass: KClass<T>, encoder: (T, PacketByteBuf) -> Unit, decoder: (PacketByteBuf) -> T, handler: ServerNetworkPacketHandler<T>)
|
||||||
|
|
||||||
|
fun sendPacketToPlayer(player: ServerPlayerEntity, packet: NetworkPacket<*>)
|
||||||
|
|
||||||
|
fun sendPacketToServer(packet: NetworkPacket<*>)
|
||||||
|
|
||||||
|
fun <T : NetworkPacket<*>> asVanillaClientBound(packet: T): Packet<ClientPlayPacketListener>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class Environment {
|
enum class Environment {
|
||||||
|
|
||||||
CLIENT,
|
CLIENT,
|
||||||
SERVER
|
SERVER
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 Cobblemon Contributors
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.item.components.HeldItemCapableComponent
|
|
||||||
import com.cobblemon.mod.common.item.components.PokemonItemComponent
|
|
||||||
import com.cobblemon.mod.common.item.RodBaitComponent
|
|
||||||
import com.cobblemon.mod.common.platform.PlatformRegistry
|
|
||||||
import net.minecraft.core.Registry
|
|
||||||
import net.minecraft.core.component.DataComponentType
|
|
||||||
import net.minecraft.core.registries.BuiltInRegistries
|
|
||||||
import net.minecraft.core.registries.Registries
|
|
||||||
import net.minecraft.resources.ResourceKey
|
|
||||||
import net.minecraft.resources.ResourceLocation
|
|
||||||
|
|
||||||
object CobblemonItemComponents : PlatformRegistry<Registry<DataComponentType<*>>, ResourceKey<Registry<DataComponentType<*>>>, DataComponentType<*>>() {
|
|
||||||
|
|
||||||
val POKEMON_ITEM: DataComponentType<PokemonItemComponent> = create("pokemon_item", DataComponentType.builder<PokemonItemComponent>()
|
|
||||||
.persistent(PokemonItemComponent.CODEC)
|
|
||||||
.networkSynchronized(PokemonItemComponent.PACKET_CODEC)
|
|
||||||
.build())
|
|
||||||
|
|
||||||
val HELD_ITEM_REP: DataComponentType<HeldItemCapableComponent> = DataComponentType.builder<HeldItemCapableComponent>()
|
|
||||||
.persistent(HeldItemCapableComponent.CODEC)
|
|
||||||
.networkSynchronized(HeldItemCapableComponent.PACKET_CODEC)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
val BAIT: DataComponentType<RodBaitComponent> = create("bait", DataComponentType.builder<RodBaitComponent>()
|
|
||||||
.persistent(RodBaitComponent.CODEC)
|
|
||||||
.networkSynchronized(RodBaitComponent.PACKET_CODEC)
|
|
||||||
.build())
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun register() {
|
|
||||||
Registry.register(BuiltInRegistries.DATA_COMPONENT_TYPE, ResourceLocation.parse("cobblemon:pokemon_item"), POKEMON_ITEM)
|
|
||||||
Registry.register(BuiltInRegistries.DATA_COMPONENT_TYPE, ResourceLocation.parse("cobblemon:bait"), BAIT)
|
|
||||||
}
|
|
||||||
|
|
||||||
override val registry = BuiltInRegistries.DATA_COMPONENT_TYPE
|
|
||||||
override val resourceKey = Registries.DATA_COMPONENT_TYPE
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -14,19 +14,21 @@ import com.cobblemon.mod.common.api.pokeball.PokeBalls
|
|||||||
import com.cobblemon.mod.common.api.pokemon.Natures
|
import com.cobblemon.mod.common.api.pokemon.Natures
|
||||||
import com.cobblemon.mod.common.api.pokemon.stats.Stats
|
import com.cobblemon.mod.common.api.pokemon.stats.Stats
|
||||||
import com.cobblemon.mod.common.api.pokemon.status.Statuses
|
import com.cobblemon.mod.common.api.pokemon.status.Statuses
|
||||||
import com.cobblemon.mod.common.api.text.blue
|
|
||||||
import com.cobblemon.mod.common.api.text.gray
|
|
||||||
import com.cobblemon.mod.common.block.BerryBlock
|
import com.cobblemon.mod.common.block.BerryBlock
|
||||||
import com.cobblemon.mod.common.block.MintBlock
|
import com.cobblemon.mod.common.block.MintBlock
|
||||||
import com.cobblemon.mod.common.block.MintBlock.MintType
|
import com.cobblemon.mod.common.block.MintBlock.MintType
|
||||||
import com.cobblemon.mod.common.client.pokedex.PokedexType
|
|
||||||
import com.cobblemon.mod.common.entity.boat.CobblemonBoatType
|
import com.cobblemon.mod.common.entity.boat.CobblemonBoatType
|
||||||
import com.cobblemon.mod.common.item.*
|
import com.cobblemon.mod.common.item.*
|
||||||
import com.cobblemon.mod.common.item.armor.CobblemonArmorTrims
|
import com.cobblemon.mod.common.item.armor.CobblemonArmorTrims
|
||||||
import com.cobblemon.mod.common.item.battle.DireHitItem
|
import com.cobblemon.mod.common.item.battle.DireHitItem
|
||||||
import com.cobblemon.mod.common.item.battle.GuardSpecItem
|
import com.cobblemon.mod.common.item.battle.GuardSpecItem
|
||||||
import com.cobblemon.mod.common.item.battle.XStatItem
|
import com.cobblemon.mod.common.item.battle.XStatItem
|
||||||
import com.cobblemon.mod.common.item.berry.*
|
import com.cobblemon.mod.common.item.berry.FriendshipRaisingBerryItem
|
||||||
|
import com.cobblemon.mod.common.item.berry.HealingBerryItem
|
||||||
|
import com.cobblemon.mod.common.item.berry.PPRestoringBerryItem
|
||||||
|
import com.cobblemon.mod.common.item.berry.PortionHealingBerryItem
|
||||||
|
import com.cobblemon.mod.common.item.berry.StatusCuringBerryItem
|
||||||
|
import com.cobblemon.mod.common.item.berry.VolatileCuringBerryItem
|
||||||
import com.cobblemon.mod.common.item.interactive.*
|
import com.cobblemon.mod.common.item.interactive.*
|
||||||
import com.cobblemon.mod.common.item.interactive.PotionItem
|
import com.cobblemon.mod.common.item.interactive.PotionItem
|
||||||
import com.cobblemon.mod.common.item.interactive.ability.AbilityChangeItem
|
import com.cobblemon.mod.common.item.interactive.ability.AbilityChangeItem
|
||||||
@@ -34,28 +36,22 @@ import com.cobblemon.mod.common.platform.PlatformRegistry
|
|||||||
import com.cobblemon.mod.common.pokeball.PokeBall
|
import com.cobblemon.mod.common.pokeball.PokeBall
|
||||||
import com.cobblemon.mod.common.pokemon.helditem.CobblemonHeldItemManager
|
import com.cobblemon.mod.common.pokemon.helditem.CobblemonHeldItemManager
|
||||||
import com.cobblemon.mod.common.util.cobblemonResource
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
import net.minecraft.core.Registry
|
import net.minecraft.block.Block
|
||||||
import net.minecraft.core.component.DataComponents
|
import net.minecraft.entity.LivingEntity
|
||||||
import net.minecraft.core.registries.BuiltInRegistries
|
import net.minecraft.entity.effect.StatusEffectInstance
|
||||||
import net.minecraft.core.registries.Registries
|
import net.minecraft.entity.effect.StatusEffects
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.item.*
|
||||||
import net.minecraft.resources.ResourceKey
|
import net.minecraft.registry.Registries
|
||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.registry.Registry
|
||||||
import net.minecraft.world.effect.MobEffectInstance
|
import net.minecraft.registry.RegistryKey
|
||||||
import net.minecraft.world.effect.MobEffects
|
import net.minecraft.registry.RegistryKeys
|
||||||
import net.minecraft.world.entity.LivingEntity
|
import net.minecraft.util.Identifier
|
||||||
import net.minecraft.world.food.FoodProperties
|
import net.minecraft.world.World
|
||||||
import net.minecraft.world.item.*
|
|
||||||
import net.minecraft.world.level.Level
|
|
||||||
import net.minecraft.world.level.block.Block
|
|
||||||
|
|
||||||
@Suppress("unused", "SameParameterValue")
|
@Suppress("unused")
|
||||||
object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<Item>>, Item>() {
|
object CobblemonItems : PlatformRegistry<Registry<Item>, RegistryKey<Registry<Item>>, Item>() {
|
||||||
override val registry: Registry<Item> = BuiltInRegistries.ITEM
|
override val registry: Registry<Item> = Registries.ITEM
|
||||||
override val resourceKey: ResourceKey<Registry<Item>> = Registries.ITEM
|
override val registryKey: RegistryKey<Registry<Item>> = RegistryKeys.ITEM
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val NPC_EDITOR = create("npc_editor", CobblemonItem(Item.Properties().stacksTo(1)))
|
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val pokeBalls = mutableListOf<PokeBallItem>()
|
val pokeBalls = mutableListOf<PokeBallItem>()
|
||||||
@@ -156,22 +152,6 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
@JvmField
|
@JvmField
|
||||||
val ANCIENT_ORIGIN_BALL = pokeBallItem(PokeBalls.ANCIENT_ORIGIN_BALL)
|
val ANCIENT_ORIGIN_BALL = pokeBallItem(PokeBalls.ANCIENT_ORIGIN_BALL)
|
||||||
|
|
||||||
val pokedexes = mutableListOf<PokedexItem>()
|
|
||||||
@JvmField
|
|
||||||
val POKEDEX_RED = pokedexItem(PokedexType.RED)
|
|
||||||
@JvmField
|
|
||||||
val POKEDEX_YELLOW = pokedexItem(PokedexType.YELLOW)
|
|
||||||
@JvmField
|
|
||||||
val POKEDEX_GREEN = pokedexItem(PokedexType.GREEN)
|
|
||||||
@JvmField
|
|
||||||
val POKEDEX_BLUE = pokedexItem(PokedexType.BLUE)
|
|
||||||
@JvmField
|
|
||||||
val POKEDEX_PINK = pokedexItem(PokedexType.PINK)
|
|
||||||
@JvmField
|
|
||||||
val POKEDEX_BLACK = pokedexItem(PokedexType.BLACK)
|
|
||||||
@JvmField
|
|
||||||
val POKEDEX_WHITE = pokedexItem(PokedexType.WHITE)
|
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val VIVICHOKE = compostableItem("vivichoke")
|
val VIVICHOKE = compostableItem("vivichoke")
|
||||||
|
|
||||||
@@ -221,9 +201,9 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
@JvmField
|
@JvmField
|
||||||
val APRICORN_LEAVES = compostableBlockItem("apricorn_leaves", CobblemonBlocks.APRICORN_LEAVES)
|
val APRICORN_LEAVES = compostableBlockItem("apricorn_leaves", CobblemonBlocks.APRICORN_LEAVES)
|
||||||
@JvmField
|
@JvmField
|
||||||
val APRICORN_BOAT = create("apricorn_boat", CobblemonBoatItem(CobblemonBoatType.APRICORN, false, Item.Properties().stacksTo(1)))
|
val APRICORN_BOAT = create("apricorn_boat", CobblemonBoatItem(CobblemonBoatType.APRICORN, false, Item.Settings().maxCount(1)))
|
||||||
@JvmField
|
@JvmField
|
||||||
val APRICORN_CHEST_BOAT = create("apricorn_chest_boat", CobblemonBoatItem(CobblemonBoatType.APRICORN, true, Item.Properties().stacksTo(1)))
|
val APRICORN_CHEST_BOAT = create("apricorn_chest_boat", CobblemonBoatItem(CobblemonBoatType.APRICORN, true, Item.Settings().maxCount(1)))
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val APRICORN_DOOR = blockItem("apricorn_door", CobblemonBlocks.APRICORN_DOOR)
|
val APRICORN_DOOR = blockItem("apricorn_door", CobblemonBlocks.APRICORN_DOOR)
|
||||||
@@ -242,25 +222,25 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
@JvmField
|
@JvmField
|
||||||
val APRICORN_STAIRS = blockItem("apricorn_stairs", CobblemonBlocks.APRICORN_STAIRS)
|
val APRICORN_STAIRS = blockItem("apricorn_stairs", CobblemonBlocks.APRICORN_STAIRS)
|
||||||
@JvmField
|
@JvmField
|
||||||
val APRICORN_SIGN = this.create("apricorn_sign", SignItem(Item.Properties().stacksTo(16), CobblemonBlocks.APRICORN_SIGN, CobblemonBlocks.APRICORN_WALL_SIGN))
|
val APRICORN_SIGN = this.create("apricorn_sign", SignItem(Item.Settings().maxCount(16), CobblemonBlocks.APRICORN_SIGN, CobblemonBlocks.APRICORN_WALL_SIGN))
|
||||||
@JvmField
|
@JvmField
|
||||||
val APRICORN_HANGING_SIGN = this.create("apricorn_hanging_sign", HangingSignItem(CobblemonBlocks.APRICORN_HANGING_SIGN, CobblemonBlocks.APRICORN_WALL_HANGING_SIGN, Item.Properties().stacksTo(16)))
|
val APRICORN_HANGING_SIGN = this.create("apricorn_hanging_sign", HangingSignItem(CobblemonBlocks.APRICORN_HANGING_SIGN, CobblemonBlocks.APRICORN_WALL_HANGING_SIGN, Item.Settings().maxCount(16)))
|
||||||
@JvmField
|
@JvmField
|
||||||
val GILDED_CHEST = this.create("gilded_chest", BlockItem(CobblemonBlocks.GILDED_CHEST, Item.Properties()))
|
val GILDED_CHEST = this.create("gilded_chest", BlockItem(CobblemonBlocks.GILDED_CHEST, Item.Settings()))
|
||||||
@JvmField
|
@JvmField
|
||||||
val BLUE_GILDED_CHEST = this.create("blue_gilded_chest", BlockItem(CobblemonBlocks.BLUE_GILDED_CHEST, Item.Properties()))
|
val BLUE_GILDED_CHEST = this.create("blue_gilded_chest", BlockItem(CobblemonBlocks.BLUE_GILDED_CHEST, Item.Settings()))
|
||||||
@JvmField
|
@JvmField
|
||||||
val YELLOW_GILDED_CHEST = this.create("yellow_gilded_chest", BlockItem(CobblemonBlocks.YELLOW_GILDED_CHEST, Item.Properties()))
|
val YELLOW_GILDED_CHEST = this.create("yellow_gilded_chest", BlockItem(CobblemonBlocks.YELLOW_GILDED_CHEST, Item.Settings()))
|
||||||
@JvmField
|
@JvmField
|
||||||
val PINK_GILDED_CHEST = this.create("pink_gilded_chest", BlockItem(CobblemonBlocks.PINK_GILDED_CHEST, Item.Properties()))
|
val PINK_GILDED_CHEST = this.create("pink_gilded_chest", BlockItem(CobblemonBlocks.PINK_GILDED_CHEST, Item.Settings()))
|
||||||
@JvmField
|
@JvmField
|
||||||
val BLACK_GILDED_CHEST = this.create("black_gilded_chest", BlockItem(CobblemonBlocks.BLACK_GILDED_CHEST, Item.Properties()))
|
val BLACK_GILDED_CHEST = this.create("black_gilded_chest", BlockItem(CobblemonBlocks.BLACK_GILDED_CHEST, Item.Settings()))
|
||||||
@JvmField
|
@JvmField
|
||||||
val WHITE_GILDED_CHEST = this.create("white_gilded_chest", BlockItem(CobblemonBlocks.WHITE_GILDED_CHEST, Item.Properties()))
|
val WHITE_GILDED_CHEST = this.create("white_gilded_chest", BlockItem(CobblemonBlocks.WHITE_GILDED_CHEST, Item.Settings()))
|
||||||
@JvmField
|
@JvmField
|
||||||
val GREEN_GILDED_CHEST = this.create("green_gilded_chest", BlockItem(CobblemonBlocks.GREEN_GILDED_CHEST, Item.Properties()))
|
val GREEN_GILDED_CHEST = this.create("green_gilded_chest", BlockItem(CobblemonBlocks.GREEN_GILDED_CHEST, Item.Settings()))
|
||||||
@JvmField
|
@JvmField
|
||||||
val GIMMIGHOUL_CHEST = this.create("gimmighoul_chest", BlockItem(CobblemonBlocks.GIMMIGHOUL_CHEST, Item.Properties()))
|
val GIMMIGHOUL_CHEST = this.create("gimmighoul_chest", BlockItem(CobblemonBlocks.GIMMIGHOUL_CHEST, Item.Settings()))
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val RESTORATION_TANK = blockItem("restoration_tank", CobblemonBlocks.RESTORATION_TANK)
|
val RESTORATION_TANK = blockItem("restoration_tank", CobblemonBlocks.RESTORATION_TANK)
|
||||||
@@ -276,8 +256,6 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
val PASTURE = blockItem("pasture", CobblemonBlocks.PASTURE)
|
val PASTURE = blockItem("pasture", CobblemonBlocks.PASTURE)
|
||||||
@JvmField
|
@JvmField
|
||||||
val DISPLAY_CASE = blockItem("display_case", CobblemonBlocks.DISPLAY_CASE)
|
val DISPLAY_CASE = blockItem("display_case", CobblemonBlocks.DISPLAY_CASE)
|
||||||
@JvmField
|
|
||||||
val LECTERN = blockItem("lectern", CobblemonBlocks.LECTERN)
|
|
||||||
|
|
||||||
// Evolution items
|
// Evolution items
|
||||||
@JvmField val LINK_CABLE = create("link_cable", LinkCableItem())
|
@JvmField val LINK_CABLE = create("link_cable", LinkCableItem())
|
||||||
@@ -318,7 +296,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
@JvmField val AUSPICIOUS_ARMOR = heldItem("auspicious_armor")
|
@JvmField val AUSPICIOUS_ARMOR = heldItem("auspicious_armor")
|
||||||
@JvmField val MALICIOUS_ARMOR = heldItem("malicious_armor")
|
@JvmField val MALICIOUS_ARMOR = heldItem("malicious_armor")
|
||||||
|
|
||||||
private val berries = mutableMapOf<ResourceLocation, BerryItem>()
|
private val berries = mutableMapOf<Identifier, BerryItem>()
|
||||||
// Plants
|
// Plants
|
||||||
@JvmField val ORAN_BERRY = berryItem("oran", HealingBerryItem(CobblemonBlocks.ORAN_BERRY) { CobblemonMechanics.berries.oranRestoreAmount })
|
@JvmField val ORAN_BERRY = berryItem("oran", HealingBerryItem(CobblemonBlocks.ORAN_BERRY) { CobblemonMechanics.berries.oranRestoreAmount })
|
||||||
@JvmField val CHERI_BERRY = berryItem("cheri", StatusCuringBerryItem(CobblemonBlocks.CHERI_BERRY, Statuses.PARALYSIS))
|
@JvmField val CHERI_BERRY = berryItem("cheri", StatusCuringBerryItem(CobblemonBlocks.CHERI_BERRY, Statuses.PARALYSIS))
|
||||||
@@ -392,9 +370,6 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
|
|
||||||
@JvmField val BERRY_JUICE = this.create("berry_juice", BerryJuiceItem())
|
@JvmField val BERRY_JUICE = this.create("berry_juice", BerryJuiceItem())
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val GALARICA_NUTS = create("galarica_nuts", GalaricaNutItem())
|
|
||||||
|
|
||||||
// Medicine
|
// Medicine
|
||||||
@JvmField
|
@JvmField
|
||||||
val RARE_CANDY = candyItem("rare_candy") { _, pokemon -> pokemon.getExperienceToNextLevel() }
|
val RARE_CANDY = candyItem("rare_candy") { _, pokemon -> pokemon.getExperienceToNextLevel() }
|
||||||
@@ -433,33 +408,32 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
@JvmField
|
@JvmField
|
||||||
val CLEVER_FEATHER = create("clever_feather", FeatherItem(Stats.SPECIAL_DEFENCE))
|
val CLEVER_FEATHER = create("clever_feather", FeatherItem(Stats.SPECIAL_DEFENCE))
|
||||||
@JvmField
|
@JvmField
|
||||||
val MEDICINAL_LEEK = heldItem("medicinal_leek", MedicinalLeekItem(CobblemonBlocks.MEDICINAL_LEEK, Item.Properties().food(FoodProperties.Builder().fast().nutrition(1).saturationModifier(0.2f).build())), "leek")
|
val MEDICINAL_LEEK = heldItem("medicinal_leek", MedicinalLeekItem(CobblemonBlocks.MEDICINAL_LEEK, Item.Settings().food(FoodComponent.Builder().snack().hunger(1).saturationModifier(0.2f).build())), "leek")
|
||||||
@JvmField
|
@JvmField
|
||||||
val ROASTED_LEEK = create("roasted_leek", Item(Item.Properties().food(FoodProperties.Builder().fast().nutrition(3).saturationModifier(0.3f).build())))
|
val ROASTED_LEEK = create("roasted_leek", Item(Item.Settings().food(FoodComponent.Builder().snack().hunger(3).saturationModifier(0.3f).build())))
|
||||||
@JvmField
|
@JvmField
|
||||||
val BRAISED_VIVICHOKE = create("braised_vivichoke", Item(Item.Properties().food(FoodProperties.Builder().nutrition(6).saturationModifier(0.6f).build())))
|
val BRAISED_VIVICHOKE = create("braised_vivichoke", Item(Item.Settings().food(FoodComponent.Builder().hunger(6).saturationModifier(0.6f).build())))
|
||||||
@JvmField
|
@JvmField
|
||||||
val VIVICHOKE_DIP = create("vivichoke_dip", object : Item(Properties().stacksTo(1)
|
val VIVICHOKE_DIP = create("vivichoke_dip", object : StewItem(Settings().maxCount(1)
|
||||||
.food(FoodProperties.Builder()
|
.food(FoodComponent.Builder()
|
||||||
.nutrition(10)
|
.hunger(10)
|
||||||
.saturationModifier(1.2F)
|
.saturationModifier(1.2F)
|
||||||
.effect(MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1F)
|
.statusEffect(StatusEffectInstance(StatusEffects.ABSORPTION, 900, 0), 1F)
|
||||||
.alwaysEdible()
|
.alwaysEdible()
|
||||||
.usingConvertsTo(Items.BOWL)
|
|
||||||
.build())) {
|
.build())) {
|
||||||
override fun finishUsingItem(stack: ItemStack, world: Level, user: LivingEntity): ItemStack {
|
override fun finishUsing(stack: ItemStack?, world: World?, user: LivingEntity?): ItemStack {
|
||||||
user.removeAllEffects()
|
user?.clearStatusEffects()
|
||||||
return super.finishUsingItem(stack, world, user)
|
return super.finishUsing(stack, world, user)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@JvmField
|
@JvmField
|
||||||
val ENERGY_ROOT = compostableItem("energy_root", EnergyRootItem(CobblemonBlocks.ENERGY_ROOT, Item.Properties().food(FoodProperties.Builder().nutrition(1).fast().saturationModifier(0.2f).build())))
|
val ENERGY_ROOT = compostableItem("energy_root", EnergyRootItem(CobblemonBlocks.ENERGY_ROOT, Item.Settings().food(FoodComponent.Builder().hunger(1).snack().saturationModifier(0.2f).build())))
|
||||||
@JvmField
|
@JvmField
|
||||||
val REVIVAL_HERB = compostableItem("revival_herb", RevivalHerbItem(CobblemonBlocks.REVIVAL_HERB))
|
val REVIVAL_HERB = compostableItem("revival_herb", RevivalHerbItem(CobblemonBlocks.REVIVAL_HERB))
|
||||||
@JvmField
|
@JvmField
|
||||||
val PEP_UP_FLOWER = compostableBlockItem("pep_up_flower", CobblemonBlocks.PEP_UP_FLOWER)
|
val PEP_UP_FLOWER = compostableBlockItem("pep_up_flower", CobblemonBlocks.PEP_UP_FLOWER)
|
||||||
@JvmField
|
@JvmField
|
||||||
val MEDICINAL_BREW = create("medicinal_brew", Item(Item.Properties()))
|
val MEDICINAL_BREW = create("medicinal_brew", Item(Item.Settings()))
|
||||||
@JvmField
|
@JvmField
|
||||||
val REMEDY = create("remedy", RemedyItem(RemedyItem.NORMAL))
|
val REMEDY = create("remedy", RemedyItem(RemedyItem.NORMAL))
|
||||||
@JvmField
|
@JvmField
|
||||||
@@ -481,7 +455,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
@JvmField
|
@JvmField
|
||||||
val HEAL_POWDER = create("heal_powder", HealPowderItem())
|
val HEAL_POWDER = create("heal_powder", HealPowderItem())
|
||||||
@JvmField
|
@JvmField
|
||||||
val LEEK_AND_POTATO_STEW = create("leek_and_potato_stew", Item(Item.Properties().food(FoodProperties.Builder().nutrition(8).saturationModifier(0.6f).usingConvertsTo(Items.BOWL).build()).stacksTo(1)))
|
val LEEK_AND_POTATO_STEW = create("leek_and_potato_stew", StewItem(Item.Settings().food(FoodComponent.Builder().hunger(8).saturationModifier(0.6f).build()).maxCount(1)))
|
||||||
@JvmField
|
@JvmField
|
||||||
val REVIVE = create("revive", ReviveItem(max = false))
|
val REVIVE = create("revive", ReviveItem(max = false))
|
||||||
@JvmField
|
@JvmField
|
||||||
@@ -693,8 +667,8 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
val CHOICE_SPECS = heldItem("choice_specs")
|
val CHOICE_SPECS = heldItem("choice_specs")
|
||||||
@JvmField
|
@JvmField
|
||||||
val CLEANSE_TAG = heldItem("cleanse_tag")
|
val CLEANSE_TAG = heldItem("cleanse_tag")
|
||||||
// @JvmField
|
@JvmField
|
||||||
// val CLEAR_AMULET = heldItem("clear_amulet")
|
val CLEAR_AMULET = heldItem("clear_amulet")
|
||||||
@JvmField
|
@JvmField
|
||||||
val COVERT_CLOAK = heldItem("covert_cloak")
|
val COVERT_CLOAK = heldItem("covert_cloak")
|
||||||
@JvmField
|
@JvmField
|
||||||
@@ -706,8 +680,6 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
@JvmField
|
@JvmField
|
||||||
val EJECT_PACK = heldItem("eject_pack")
|
val EJECT_PACK = heldItem("eject_pack")
|
||||||
@JvmField
|
@JvmField
|
||||||
val ELECTRIC_SEED = heldItem("electric_seed")
|
|
||||||
@JvmField
|
|
||||||
val EVERSTONE = heldItem("everstone")
|
val EVERSTONE = heldItem("everstone")
|
||||||
@JvmField
|
@JvmField
|
||||||
val EVIOLITE = heldItem("eviolite")
|
val EVIOLITE = heldItem("eviolite")
|
||||||
@@ -726,17 +698,15 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
@JvmField
|
@JvmField
|
||||||
val FOCUS_SASH = heldItem("focus_sash")
|
val FOCUS_SASH = heldItem("focus_sash")
|
||||||
@JvmField
|
@JvmField
|
||||||
val GRASSY_SEED = heldItem("grassy_seed")
|
val GRIP_CLAW = heldItem("grip_claw")
|
||||||
// @JvmField
|
|
||||||
// val GRIP_CLAW = heldItem("grip_claw")
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val HARD_STONE = heldItem("hard_stone")
|
val HARD_STONE = heldItem("hard_stone")
|
||||||
@JvmField
|
@JvmField
|
||||||
val HEAVY_DUTY_BOOTS = heldItem("heavy_duty_boots")
|
val HEAVY_DUTY_BOOTS = heldItem("heavy_duty_boots")
|
||||||
@JvmField
|
@JvmField
|
||||||
val IRON_BALL = heldItem("iron_ball")
|
val IRON_BALL = heldItem("iron_ball")
|
||||||
// @JvmField
|
@JvmField
|
||||||
// val LAGGING_TAIL = heldItem("lagging_tail")
|
val LAGGING_TAIL = heldItem("lagging_tail")
|
||||||
@JvmField
|
@JvmField
|
||||||
val LEFTOVERS = heldItem("leftovers")
|
val LEFTOVERS = heldItem("leftovers")
|
||||||
@JvmField
|
@JvmField
|
||||||
@@ -749,8 +719,8 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
val LOADED_DICE = heldItem("loaded_dice")
|
val LOADED_DICE = heldItem("loaded_dice")
|
||||||
@JvmField
|
@JvmField
|
||||||
val LUCKY_EGG = heldItem("lucky_egg")
|
val LUCKY_EGG = heldItem("lucky_egg")
|
||||||
// @JvmField
|
@JvmField
|
||||||
// val LUMINOUS_MOSS = heldItem("luminous_moss")
|
val LUMINOUS_MOSS = heldItem("luminous_moss")
|
||||||
@JvmField
|
@JvmField
|
||||||
val MAGNET = heldItem("magnet")
|
val MAGNET = heldItem("magnet")
|
||||||
@JvmField
|
@JvmField
|
||||||
@@ -778,8 +748,6 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
@JvmField
|
@JvmField
|
||||||
val POWER_WEIGHT = heldItem("power_weight")
|
val POWER_WEIGHT = heldItem("power_weight")
|
||||||
@JvmField
|
@JvmField
|
||||||
val PSYCHIC_SEED = heldItem("psychic_seed")
|
|
||||||
@JvmField
|
|
||||||
val PROTECTIVE_PADS = heldItem("protective_pads")
|
val PROTECTIVE_PADS = heldItem("protective_pads")
|
||||||
@JvmField
|
@JvmField
|
||||||
val PUNCHING_GLOVE = heldItem("punching_glove")
|
val PUNCHING_GLOVE = heldItem("punching_glove")
|
||||||
@@ -840,8 +808,6 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
@JvmField
|
@JvmField
|
||||||
val MIRROR_HERB = compostableHeldItem("mirror_herb", null, 1F)
|
val MIRROR_HERB = compostableHeldItem("mirror_herb", null, 1F)
|
||||||
@JvmField
|
@JvmField
|
||||||
val MISTY_SEED = heldItem("misty_seed")
|
|
||||||
@JvmField
|
|
||||||
val POWER_HERB = compostableHeldItem("power_herb", null, 1F)
|
val POWER_HERB = compostableHeldItem("power_herb", null, 1F)
|
||||||
@JvmField
|
@JvmField
|
||||||
val WHITE_HERB = compostableHeldItem("white_herb", null, 1F)
|
val WHITE_HERB = compostableHeldItem("white_herb", null, 1F)
|
||||||
@@ -926,11 +892,11 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
val SUSPICIOUS_SHERD = noSettingsItem("suspicious_sherd")
|
val SUSPICIOUS_SHERD = noSettingsItem("suspicious_sherd")
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val TUMBLESTONE = this.create("tumblestone", TumblestoneItem(Item.Properties(), CobblemonBlocks.SMALL_BUDDING_TUMBLESTONE))
|
val TUMBLESTONE = this.create("tumblestone", TumblestoneItem(Item.Settings(), CobblemonBlocks.SMALL_BUDDING_TUMBLESTONE))
|
||||||
@JvmField
|
@JvmField
|
||||||
val BLACK_TUMBLESTONE = this.create("black_tumblestone", TumblestoneItem(Item.Properties(), CobblemonBlocks.SMALL_BUDDING_BLACK_TUMBLESTONE))
|
val BLACK_TUMBLESTONE = this.create("black_tumblestone", TumblestoneItem(Item.Settings(), CobblemonBlocks.SMALL_BUDDING_BLACK_TUMBLESTONE))
|
||||||
@JvmField
|
@JvmField
|
||||||
val SKY_TUMBLESTONE = this.create("sky_tumblestone", TumblestoneItem(Item.Properties(), CobblemonBlocks.SMALL_BUDDING_SKY_TUMBLESTONE))
|
val SKY_TUMBLESTONE = this.create("sky_tumblestone", TumblestoneItem(Item.Settings(), CobblemonBlocks.SMALL_BUDDING_SKY_TUMBLESTONE))
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val SMALL_BUDDING_TUMBLESTONE = blockItem("small_budding_tumblestone", CobblemonBlocks.SMALL_BUDDING_TUMBLESTONE)
|
val SMALL_BUDDING_TUMBLESTONE = blockItem("small_budding_tumblestone", CobblemonBlocks.SMALL_BUDDING_TUMBLESTONE)
|
||||||
@@ -966,221 +932,12 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
@JvmField
|
@JvmField
|
||||||
val BLACK_TUMBLESTONE_BLOCK = blockItem("black_tumblestone_block", CobblemonBlocks.BLACK_TUMBLESTONE_BLOCK)
|
val BLACK_TUMBLESTONE_BLOCK = blockItem("black_tumblestone_block", CobblemonBlocks.BLACK_TUMBLESTONE_BLOCK)
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val POKEROD_SMITHING_TEMPLATE = create("pokerod_smithing_template", SmithingTemplateItem(
|
|
||||||
Component.translatable("item.minecraft.fishing_rod").blue(),
|
|
||||||
Component.translatable("item.cobblemon.smithing_template.pokerod.ingredients").blue(),
|
|
||||||
Component.translatable("upgrade.cobblemon.pokerod").gray(),
|
|
||||||
Component.translatable("item.cobblemon.smithing_template.pokerod.base_slot_description"),
|
|
||||||
Component.translatable("item.cobblemon.smithing_template.pokerod.additions_slot_description"),
|
|
||||||
listOf(cobblemonResource("item/empty_slot_fishing_rod")),
|
|
||||||
listOf(cobblemonResource("item/empty_slot_pokeball"))
|
|
||||||
))
|
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_TUMBLESTONE = blockItem("polished_tumblestone", CobblemonBlocks.POLISHED_TUMBLESTONE)
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_TUMBLESTONE_STAIRS = blockItem("polished_tumblestone_stairs", CobblemonBlocks.POLISHED_TUMBLESTONE_STAIRS)
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_TUMBLESTONE_SLAB = blockItem("polished_tumblestone_slab", CobblemonBlocks.POLISHED_TUMBLESTONE_SLAB)
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_TUMBLESTONE_WALL = blockItem("polished_tumblestone_wall", CobblemonBlocks.POLISHED_TUMBLESTONE_WALL)
|
|
||||||
@JvmField
|
|
||||||
val CHISELED_POLISHED_TUMBLESTONE = blockItem("chiseled_polished_tumblestone", CobblemonBlocks.CHISELED_POLISHED_TUMBLESTONE)
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_TUMBLESTONE = blockItem("smooth_tumblestone", CobblemonBlocks.SMOOTH_TUMBLESTONE)
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_TUMBLESTONE_STAIRS = blockItem("smooth_tumblestone_stairs", CobblemonBlocks.SMOOTH_TUMBLESTONE_STAIRS)
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_TUMBLESTONE_SLAB = blockItem("smooth_tumblestone_slab", CobblemonBlocks.SMOOTH_TUMBLESTONE_SLAB)
|
|
||||||
@JvmField
|
|
||||||
val TUMBLESTONE_BRICKS = blockItem("tumblestone_bricks", CobblemonBlocks.TUMBLESTONE_BRICKS)
|
|
||||||
@JvmField
|
|
||||||
val TUMBLESTONE_BRICK_STAIRS = blockItem("tumblestone_brick_stairs", CobblemonBlocks.TUMBLESTONE_BRICK_STAIRS)
|
|
||||||
@JvmField
|
|
||||||
val TUMBLESTONE_BRICK_SLAB = blockItem("tumblestone_brick_slab", CobblemonBlocks.TUMBLESTONE_BRICK_SLAB)
|
|
||||||
@JvmField
|
|
||||||
val TUMBLESTONE_BRICK_WALL = blockItem("tumblestone_brick_wall", CobblemonBlocks.TUMBLESTONE_BRICK_WALL)
|
|
||||||
@JvmField
|
|
||||||
val CHISELED_TUMBLESTONE_BRICKS = blockItem("chiseled_tumblestone_bricks", CobblemonBlocks.CHISELED_TUMBLESTONE_BRICKS)
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_SKY_TUMBLESTONE = blockItem("polished_sky_tumblestone", CobblemonBlocks.POLISHED_SKY_TUMBLESTONE)
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_SKY_TUMBLESTONE_STAIRS = blockItem("polished_sky_tumblestone_stairs", CobblemonBlocks.POLISHED_SKY_TUMBLESTONE_STAIRS)
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_SKY_TUMBLESTONE_SLAB = blockItem("polished_sky_tumblestone_slab", CobblemonBlocks.POLISHED_SKY_TUMBLESTONE_SLAB)
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_SKY_TUMBLESTONE_WALL = blockItem("polished_sky_tumblestone_wall", CobblemonBlocks.POLISHED_SKY_TUMBLESTONE_WALL)
|
|
||||||
@JvmField
|
|
||||||
val CHISELED_POLISHED_SKY_TUMBLESTONE = blockItem("chiseled_polished_sky_tumblestone", CobblemonBlocks.CHISELED_POLISHED_SKY_TUMBLESTONE)
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_SKY_TUMBLESTONE = blockItem("smooth_sky_tumblestone", CobblemonBlocks.SMOOTH_SKY_TUMBLESTONE)
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_SKY_TUMBLESTONE_STAIRS = blockItem("smooth_sky_tumblestone_stairs", CobblemonBlocks.SMOOTH_SKY_TUMBLESTONE_STAIRS)
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_SKY_TUMBLESTONE_SLAB = blockItem("smooth_sky_tumblestone_slab", CobblemonBlocks.SMOOTH_SKY_TUMBLESTONE_SLAB)
|
|
||||||
@JvmField
|
|
||||||
val SKY_TUMBLESTONE_BRICKS = blockItem("sky_tumblestone_bricks", CobblemonBlocks.SKY_TUMBLESTONE_BRICKS)
|
|
||||||
@JvmField
|
|
||||||
val SKY_TUMBLESTONE_BRICK_STAIRS = blockItem("sky_tumblestone_brick_stairs", CobblemonBlocks.SKY_TUMBLESTONE_BRICK_STAIRS)
|
|
||||||
@JvmField
|
|
||||||
val SKY_TUMBLESTONE_BRICK_SLAB = blockItem("sky_tumblestone_brick_slab", CobblemonBlocks.SKY_TUMBLESTONE_BRICK_SLAB)
|
|
||||||
@JvmField
|
|
||||||
val SKY_TUMBLESTONE_BRICK_WALL = blockItem("sky_tumblestone_brick_wall", CobblemonBlocks.SKY_TUMBLESTONE_BRICK_WALL)
|
|
||||||
@JvmField
|
|
||||||
val CHISELED_SKY_TUMBLESTONE_BRICKS = blockItem("chiseled_sky_tumblestone_bricks", CobblemonBlocks.CHISELED_SKY_TUMBLESTONE_BRICKS)
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_BLACK_TUMBLESTONE = blockItem("polished_black_tumblestone", CobblemonBlocks.POLISHED_BLACK_TUMBLESTONE)
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_BLACK_TUMBLESTONE_STAIRS = blockItem("polished_black_tumblestone_stairs", CobblemonBlocks.POLISHED_BLACK_TUMBLESTONE_STAIRS)
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_BLACK_TUMBLESTONE_SLAB = blockItem("polished_black_tumblestone_slab", CobblemonBlocks.POLISHED_BLACK_TUMBLESTONE_SLAB)
|
|
||||||
@JvmField
|
|
||||||
val POLISHED_BLACK_TUMBLESTONE_WALL = blockItem("polished_black_tumblestone_wall", CobblemonBlocks.POLISHED_BLACK_TUMBLESTONE_WALL)
|
|
||||||
@JvmField
|
|
||||||
val CHISELED_POLISHED_BLACK_TUMBLESTONE = blockItem("chiseled_polished_black_tumblestone", CobblemonBlocks.CHISELED_POLISHED_BLACK_TUMBLESTONE)
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_BLACK_TUMBLESTONE = blockItem("smooth_black_tumblestone", CobblemonBlocks.SMOOTH_BLACK_TUMBLESTONE)
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_BLACK_TUMBLESTONE_STAIRS = blockItem("smooth_black_tumblestone_stairs", CobblemonBlocks.SMOOTH_BLACK_TUMBLESTONE_STAIRS)
|
|
||||||
@JvmField
|
|
||||||
val SMOOTH_BLACK_TUMBLESTONE_SLAB = blockItem("smooth_black_tumblestone_slab", CobblemonBlocks.SMOOTH_BLACK_TUMBLESTONE_SLAB)
|
|
||||||
@JvmField
|
|
||||||
val BLACK_TUMBLESTONE_BRICKS = blockItem("black_tumblestone_bricks", CobblemonBlocks.BLACK_TUMBLESTONE_BRICKS)
|
|
||||||
@JvmField
|
|
||||||
val BLACK_TUMBLESTONE_BRICK_STAIRS = blockItem("black_tumblestone_brick_stairs", CobblemonBlocks.BLACK_TUMBLESTONE_BRICK_STAIRS)
|
|
||||||
@JvmField
|
|
||||||
val BLACK_TUMBLESTONE_BRICK_SLAB = blockItem("black_tumblestone_brick_slab", CobblemonBlocks.BLACK_TUMBLESTONE_BRICK_SLAB)
|
|
||||||
@JvmField
|
|
||||||
val BLACK_TUMBLESTONE_BRICK_WALL = blockItem("black_tumblestone_brick_wall", CobblemonBlocks.BLACK_TUMBLESTONE_BRICK_WALL)
|
|
||||||
@JvmField
|
|
||||||
val CHISELED_BLACK_TUMBLESTONE_BRICKS = blockItem("chiseled_black_tumblestone_bricks", CobblemonBlocks.CHISELED_BLACK_TUMBLESTONE_BRICKS)
|
|
||||||
|
|
||||||
@JvmField
|
|
||||||
val FIRE_STONE_BLOCK = blockItem("fire_stone_block", CobblemonBlocks.FIRE_STONE_BLOCK)
|
|
||||||
@JvmField
|
|
||||||
val WATER_STONE_BLOCK = blockItem("water_stone_block", CobblemonBlocks.WATER_STONE_BLOCK)
|
|
||||||
@JvmField
|
|
||||||
val THUNDER_STONE_BLOCK = blockItem("thunder_stone_block", CobblemonBlocks.THUNDER_STONE_BLOCK)
|
|
||||||
@JvmField
|
|
||||||
val LEAF_STONE_BLOCK = blockItem("leaf_stone_block", CobblemonBlocks.LEAF_STONE_BLOCK)
|
|
||||||
@JvmField
|
|
||||||
val ICE_STONE_BLOCK = blockItem("ice_stone_block", CobblemonBlocks.ICE_STONE_BLOCK)
|
|
||||||
@JvmField
|
|
||||||
val SUN_STONE_BLOCK = blockItem("sun_stone_block", CobblemonBlocks.SUN_STONE_BLOCK)
|
|
||||||
@JvmField
|
|
||||||
val MOON_STONE_BLOCK = blockItem("moon_stone_block", CobblemonBlocks.MOON_STONE_BLOCK)
|
|
||||||
@JvmField
|
|
||||||
val SHINY_STONE_BLOCK = blockItem("shiny_stone_block", CobblemonBlocks.SHINY_STONE_BLOCK)
|
|
||||||
@JvmField
|
|
||||||
val DAWN_STONE_BLOCK = blockItem("dawn_stone_block", CobblemonBlocks.DAWN_STONE_BLOCK)
|
|
||||||
@JvmField
|
|
||||||
val DUSK_STONE_BLOCK = blockItem("dusk_stone_block", CobblemonBlocks.DUSK_STONE_BLOCK)
|
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val AUTOMATON_ARMOR_TRIM_SMITHING_TEMPLATE: SmithingTemplateItem = this.create(
|
val AUTOMATON_ARMOR_TRIM_SMITHING_TEMPLATE: SmithingTemplateItem = this.create(
|
||||||
"automaton_armor_trim_smithing_template",
|
"automaton_armor_trim_smithing_template",
|
||||||
SmithingTemplateItem.createArmorTrimTemplate(CobblemonArmorTrims.AUTOMATON)
|
SmithingTemplateItem.of(CobblemonArmorTrims.AUTOMATON)
|
||||||
)
|
)
|
||||||
|
|
||||||
val pokeRods = mutableListOf<PokerodItem>()
|
|
||||||
@JvmField
|
|
||||||
val POKE_ROD = pokerodItem(cobblemonResource("poke_rod"))
|
|
||||||
@JvmField
|
|
||||||
val CITRINE_ROD = pokerodItem(cobblemonResource("citrine_rod"))
|
|
||||||
@JvmField
|
|
||||||
val VERDANT_ROD = pokerodItem(cobblemonResource("verdant_rod"))
|
|
||||||
@JvmField
|
|
||||||
val AZURE_ROD = pokerodItem(cobblemonResource("azure_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ROSEATE_ROD = pokerodItem(cobblemonResource("roseate_rod"))
|
|
||||||
@JvmField
|
|
||||||
val SLATE_ROD = pokerodItem(cobblemonResource("slate_rod"))
|
|
||||||
@JvmField
|
|
||||||
val PREMIER_ROD = pokerodItem(cobblemonResource("premier_rod"))
|
|
||||||
@JvmField
|
|
||||||
val GREAT_ROD = pokerodItem(cobblemonResource("great_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ULTRA_ROD = pokerodItem(cobblemonResource("ultra_rod"))
|
|
||||||
@JvmField
|
|
||||||
val SAFARI_ROD = pokerodItem(cobblemonResource("safari_rod"))
|
|
||||||
@JvmField
|
|
||||||
val FAST_ROD = pokerodItem(cobblemonResource("fast_rod"))
|
|
||||||
@JvmField
|
|
||||||
val LEVEL_ROD = pokerodItem(cobblemonResource("level_rod"))
|
|
||||||
@JvmField
|
|
||||||
val LURE_ROD = pokerodItem(cobblemonResource("lure_rod"))
|
|
||||||
@JvmField
|
|
||||||
val HEAVY_ROD = pokerodItem(cobblemonResource("heavy_rod"))
|
|
||||||
@JvmField
|
|
||||||
val LOVE_ROD = pokerodItem(cobblemonResource("love_rod"))
|
|
||||||
@JvmField
|
|
||||||
val FRIEND_ROD = pokerodItem(cobblemonResource("friend_rod"))
|
|
||||||
@JvmField
|
|
||||||
val MOON_ROD = pokerodItem(cobblemonResource("moon_rod"))
|
|
||||||
@JvmField
|
|
||||||
val SPORT_ROD = pokerodItem(cobblemonResource("sport_rod"))
|
|
||||||
@JvmField
|
|
||||||
val PARK_ROD = pokerodItem(cobblemonResource("park_rod"))
|
|
||||||
@JvmField
|
|
||||||
val NET_ROD = pokerodItem(cobblemonResource("net_rod"))
|
|
||||||
@JvmField
|
|
||||||
val DIVE_ROD = pokerodItem(cobblemonResource("dive_rod"))
|
|
||||||
@JvmField
|
|
||||||
val NEST_ROD = pokerodItem(cobblemonResource("nest_rod"))
|
|
||||||
@JvmField
|
|
||||||
val REPEAT_ROD = pokerodItem(cobblemonResource("repeat_rod"))
|
|
||||||
@JvmField
|
|
||||||
val TIMER_ROD = pokerodItem(cobblemonResource("timer_rod"))
|
|
||||||
@JvmField
|
|
||||||
val LUXURY_ROD = pokerodItem(cobblemonResource("luxury_rod"))
|
|
||||||
@JvmField
|
|
||||||
val DUSK_ROD = pokerodItem(cobblemonResource("dusk_rod"))
|
|
||||||
@JvmField
|
|
||||||
val HEAL_ROD = pokerodItem(cobblemonResource("heal_rod"))
|
|
||||||
@JvmField
|
|
||||||
val QUICK_ROD = pokerodItem(cobblemonResource("quick_rod"))
|
|
||||||
@JvmField
|
|
||||||
val DREAM_ROD = pokerodItem(cobblemonResource("dream_rod"))
|
|
||||||
@JvmField
|
|
||||||
val BEAST_ROD = pokerodItem(cobblemonResource("beast_rod"))
|
|
||||||
@JvmField
|
|
||||||
val MASTER_ROD = pokerodItem(cobblemonResource("master_rod"))
|
|
||||||
@JvmField
|
|
||||||
val CHERISH_ROD = pokerodItem(cobblemonResource("cherish_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ANCIENT_POKE_ROD = pokerodItem(cobblemonResource("ancient_poke_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ANCIENT_CITRINE_ROD = pokerodItem(cobblemonResource("ancient_citrine_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ANCIENT_VERDANT_ROD = pokerodItem(cobblemonResource("ancient_verdant_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ANCIENT_AZURE_ROD = pokerodItem(cobblemonResource("ancient_azure_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ANCIENT_ROSEATE_ROD = pokerodItem(cobblemonResource("ancient_roseate_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ANCIENT_SLATE_ROD = pokerodItem(cobblemonResource("ancient_slate_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ANCIENT_IVORY_ROD = pokerodItem(cobblemonResource("ancient_ivory_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ANCIENT_GREAT_ROD = pokerodItem(cobblemonResource("ancient_great_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ANCIENT_ULTRA_ROD = pokerodItem(cobblemonResource("ancient_ultra_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ANCIENT_FEATHER_ROD = pokerodItem(cobblemonResource("ancient_feather_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ANCIENT_WING_ROD = pokerodItem(cobblemonResource("ancient_wing_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ANCIENT_JET_ROD = pokerodItem(cobblemonResource("ancient_jet_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ANCIENT_HEAVY_ROD = pokerodItem(cobblemonResource("ancient_heavy_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ANCIENT_LEADEN_ROD = pokerodItem(cobblemonResource("ancient_leaden_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ANCIENT_GIGATON_ROD = pokerodItem(cobblemonResource("ancient_gigaton_rod"))
|
|
||||||
@JvmField
|
|
||||||
val ANCIENT_ORIGIN_ROD = pokerodItem(cobblemonResource("ancient_origin_rod"))
|
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
@JvmField
|
@JvmField
|
||||||
val POKEMON_MODEL = this.create("pokemon_model", PokemonItem())
|
val POKEMON_MODEL = this.create("pokemon_model", PokemonItem())
|
||||||
@@ -1228,12 +985,10 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
val STEEL_GEM = noSettingsItem("steel_gem")
|
val STEEL_GEM = noSettingsItem("steel_gem")
|
||||||
@JvmField
|
@JvmField
|
||||||
val FAIRY_GEM = noSettingsItem("fairy_gem")
|
val FAIRY_GEM = noSettingsItem("fairy_gem")
|
||||||
//@JvmField
|
|
||||||
//val BINDING_SOIL = blockItem("binding_soil", CobblemonBlocks.BINDING_SOIL)
|
|
||||||
|
|
||||||
private fun blockItem(name: String, block: Block): BlockItem = this.create(name, BlockItem(block, Item.Properties()))
|
private fun blockItem(name: String, block: Block): BlockItem = this.create(name, BlockItem(block, Item.Settings()))
|
||||||
|
|
||||||
private fun noSettingsItem(name: String): CobblemonItem = this.create(name, CobblemonItem(Item.Properties()))
|
private fun noSettingsItem(name: String): CobblemonItem = this.create(name, CobblemonItem(Item.Settings()))
|
||||||
|
|
||||||
fun berries() = this.berries.toMap()
|
fun berries() = this.berries.toMap()
|
||||||
|
|
||||||
@@ -1248,22 +1003,9 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
|
|
||||||
private fun candyItem(name: String, calculator: CandyItem.Calculator): CandyItem = this.create(name, CandyItem(calculator))
|
private fun candyItem(name: String, calculator: CandyItem.Calculator): CandyItem = this.create(name, CandyItem(calculator))
|
||||||
|
|
||||||
private fun pokerodItem(pokeRodId: ResourceLocation): PokerodItem {
|
|
||||||
val settings = Item.Properties().stacksTo(1).durability(256)
|
|
||||||
val item = create(pokeRodId.path, PokerodItem(pokeRodId, settings))
|
|
||||||
pokeRods.add(item)
|
|
||||||
return item
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun pokedexItem(type: PokedexType): PokedexItem {
|
|
||||||
val item = create("pokedex_${type.name.lowercase()}", PokedexItem(type))
|
|
||||||
pokedexes.add(item)
|
|
||||||
return item
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun heldItem(name: String, remappedName: String? = null): CobblemonItem = create(
|
private fun heldItem(name: String, remappedName: String? = null): CobblemonItem = create(
|
||||||
name,
|
name,
|
||||||
CobblemonItem(Item.Properties()).also {
|
CobblemonItem(Item.Settings()).also {
|
||||||
if (remappedName != null) {
|
if (remappedName != null) {
|
||||||
CobblemonHeldItemManager.registerRemap(it, remappedName)
|
CobblemonHeldItemManager.registerRemap(it, remappedName)
|
||||||
}
|
}
|
||||||
@@ -1334,7 +1076,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun compostableItem(name: String, item: Item? = null, increaseLevelChance: Float = .65f): Item {
|
private fun compostableItem(name: String, item: Item? = null, increaseLevelChance: Float = .65f): Item {
|
||||||
val createdItem = this.create(name, item ?: Item(Item.Properties()))
|
val createdItem = this.create(name, item ?: Item(Item.Settings()))
|
||||||
compostable(createdItem, increaseLevelChance)
|
compostable(createdItem, increaseLevelChance)
|
||||||
return createdItem
|
return createdItem
|
||||||
}
|
}
|
||||||
@@ -1351,4 +1093,4 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
|||||||
return createdItem
|
return createdItem
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,35 +10,32 @@ package com.cobblemon.mod.common
|
|||||||
|
|
||||||
import com.bedrockk.molang.Expression
|
import com.bedrockk.molang.Expression
|
||||||
import com.cobblemon.mod.common.api.data.DataRegistry
|
import com.cobblemon.mod.common.api.data.DataRegistry
|
||||||
import com.cobblemon.mod.common.api.molang.ExpressionLike
|
|
||||||
import com.cobblemon.mod.common.api.reactive.SimpleObservable
|
import com.cobblemon.mod.common.api.reactive.SimpleObservable
|
||||||
import com.cobblemon.mod.common.mechanics.BerriesMechanic
|
import com.cobblemon.mod.common.mechanics.BerriesMechanic
|
||||||
import com.cobblemon.mod.common.mechanics.PotionsMechanic
|
import com.cobblemon.mod.common.mechanics.PotionsMechanic
|
||||||
import com.cobblemon.mod.common.mechanics.RemediesMechanic
|
import com.cobblemon.mod.common.mechanics.RemediesMechanic
|
||||||
import com.cobblemon.mod.common.util.adapters.ExpressionAdapter
|
import com.cobblemon.mod.common.util.adapters.ExpressionAdapter
|
||||||
import com.cobblemon.mod.common.util.adapters.ExpressionLikeAdapter
|
|
||||||
import com.cobblemon.mod.common.util.cobblemonResource
|
import com.cobblemon.mod.common.util.cobblemonResource
|
||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.resource.ResourceManager
|
||||||
import net.minecraft.server.level.ServerPlayer
|
import net.minecraft.resource.ResourceType
|
||||||
import net.minecraft.server.packs.PackType
|
import net.minecraft.server.network.ServerPlayerEntity
|
||||||
import net.minecraft.server.packs.resources.ResourceManager
|
import net.minecraft.util.Identifier
|
||||||
|
|
||||||
object CobblemonMechanics : DataRegistry {
|
object CobblemonMechanics : DataRegistry {
|
||||||
override val id: ResourceLocation = cobblemonResource("mechanics")
|
override val id: Identifier = cobblemonResource("mechanics")
|
||||||
override val type = PackType.SERVER_DATA
|
override val type = ResourceType.SERVER_DATA
|
||||||
override val observable = SimpleObservable<CobblemonMechanics>()
|
override val observable = SimpleObservable<CobblemonMechanics>()
|
||||||
val gson = GsonBuilder()
|
val gson = GsonBuilder()
|
||||||
.setPrettyPrinting()
|
.setPrettyPrinting()
|
||||||
.registerTypeAdapter(Expression::class.java, ExpressionAdapter)
|
.registerTypeAdapter(Expression::class.java, ExpressionAdapter)
|
||||||
.registerTypeAdapter(ExpressionLike::class.java, ExpressionLikeAdapter)
|
|
||||||
.create()
|
.create()
|
||||||
|
|
||||||
var remedies = RemediesMechanic()
|
var remedies = RemediesMechanic()
|
||||||
var berries = BerriesMechanic()
|
var berries = BerriesMechanic()
|
||||||
var potions = PotionsMechanic()
|
var potions = PotionsMechanic()
|
||||||
|
|
||||||
override fun sync(player: ServerPlayer) {}
|
override fun sync(player: ServerPlayerEntity) {}
|
||||||
override fun reload(manager: ResourceManager) {
|
override fun reload(manager: ResourceManager) {
|
||||||
remedies = loadMechanic(manager, "remedies", RemediesMechanic::class.java)
|
remedies = loadMechanic(manager, "remedies", RemediesMechanic::class.java)
|
||||||
berries = loadMechanic(manager, "berries", BerriesMechanic::class.java)
|
berries = loadMechanic(manager, "berries", BerriesMechanic::class.java)
|
||||||
@@ -46,7 +43,7 @@ object CobblemonMechanics : DataRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun <T> loadMechanic(manager: ResourceManager, name: String, clazz: Class<T>): T {
|
private fun <T> loadMechanic(manager: ResourceManager, name: String, clazz: Class<T>): T {
|
||||||
manager.getResourceOrThrow(cobblemonResource("mechanics/$name.json")).open().use {
|
manager.getResourceOrThrow(cobblemonResource("mechanics/$name.json")).inputStream.use {
|
||||||
return gson.fromJson(it.reader(), clazz)
|
return gson.fromJson(it.reader(), clazz)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user