mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-11-01 22:08:52 -05:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17ca9a31f1 | ||
|
|
c851f57e36 | ||
|
|
2b3497e63d | ||
|
|
c014efa9a6 | ||
|
|
f63970163a | ||
|
|
b34adc6b57 |
No files matched your search
@@ -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
|
|
||||||
@@ -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
|
||||||
@@ -35,9 +33,3 @@ common/src/main/resources/assets/cobblemon/showdown
|
|||||||
# Generated files
|
# Generated files
|
||||||
*/generated/resources/*
|
*/generated/resources/*
|
||||||
/fabric/src/generated/resources/cobblemon-common.accesswidener
|
/fabric/src/generated/resources/cobblemon-common.accesswidener
|
||||||
/.ignored/
|
|
||||||
common/.fabric
|
|
||||||
.kotlin/
|
|
||||||
|
|
||||||
# MacOS
|
|
||||||
.DS_Store
|
|
||||||
+28
-149
@@ -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
|
||||||
|
when: manual
|
||||||
|
cache:
|
||||||
|
key: "$CI_COMMIT_REF_NAME"
|
||||||
|
policy: pull
|
||||||
|
paths:
|
||||||
|
- forge/build/libs/*.jar
|
||||||
|
- fabric/build/libs/*.jar
|
||||||
script:
|
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
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<!-- 1. START HERE: (Before filling all this out, please quickly go to the list of all issues: (https://gitlab.com/cable-mc/cobblemon/-/issues/?sort=created_date&state=all) and do a quick search to see if your issue has already been reported. If it has, please add a comment to the existing issue instead of creating a new one.)-->
|
|
||||||
<!-- 2. If the issue was not already reported, please fill out the following template. -->
|
|
||||||
<!-- 3. If you do not know something, don't worry! Just fill out as much as you can to make sure the issue can get fixed asap. -->
|
|
||||||
|
|
||||||
## Summary
|
|
||||||
(Please summarize the bug encountered concisely)
|
|
||||||
|
|
||||||
## Steps to reproduce
|
|
||||||
(How one can reproduce the issue - this is very important)
|
|
||||||
|
|
||||||
## What is the current bug behavior?
|
|
||||||
(What actually happens)
|
|
||||||
|
|
||||||
## What is the expected correct behavior?
|
|
||||||
(What you should see instead)
|
|
||||||
|
|
||||||
## Cobblemon Version and Mod Loader
|
|
||||||
(Are you using Forge or Fabric? And what version of Cobblemon are you using?)
|
|
||||||
|
|
||||||
## Mods used besides Cobblemon
|
|
||||||
(Did you have any other mods installed besides Cobblemon? If so, please list them here)
|
|
||||||
|
|
||||||
## Relevant logs, screenshots and/or videos
|
|
||||||
(Paste any relevant logs - use code blocks (```) at the start and end to format console output, logs, and code, as
|
|
||||||
it's very hard to read otherwise. Or just put a link here)
|
|
||||||
|
|
||||||
## Additional Information
|
|
||||||
(If you can, link to the line of code that might be responsible for the problem, or any other info that might be useful)
|
|
||||||
|
|
||||||
/label ~bug
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<!-- 1. START HERE: (Before filling all this out, please quickly go to the list of all issues: (https://gitlab.com/cable-mc/cobblemon/-/issues/?sort=created_date&state=all) and do a quick search to see if your feature was already requested. If it is, please add a comment to the existing issue instead of creating a new one.)-->
|
|
||||||
<!-- 2. If the feature request was not already reported, please fill out the following template. -->
|
|
||||||
<!-- 3. If you do not know something, don't worry! Just fill out as much as you can. -->
|
|
||||||
<!-- 4. The more info you provide here, the greater the chance of it being considered by the Design team. -->
|
|
||||||
|
|
||||||
## Summary
|
|
||||||
(Please summarize your feature request concisely)
|
|
||||||
|
|
||||||
## What are the projected benefits of this feature?
|
|
||||||
- (List)
|
|
||||||
- (benefits)
|
|
||||||
- (here)
|
|
||||||
|
|
||||||
## What could speak against this feature?
|
|
||||||
- (List)
|
|
||||||
- (possible)
|
|
||||||
- (cons)
|
|
||||||
|
|
||||||
## Why do you think the benefits outweigh the cons?
|
|
||||||
(Explain why you think the benefits outweigh the cons)
|
|
||||||
|
|
||||||
## Mods involved besides Cobblemon
|
|
||||||
(Does your suggestion require any other mods besides Cobblemon? If so, please list them here)
|
|
||||||
|
|
||||||
## Sketches, screenshots and/or videos
|
|
||||||
(Feel free to add any sketches, screenshots or videos that might help the Design team understand your suggestion)
|
|
||||||
|
|
||||||
## Additional Information
|
|
||||||
(Is there anything else you would like to add?)
|
|
||||||
|
|
||||||
/label ~feature ~suggestion ~needs-design
|
|
||||||
+112
-1489
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
|
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
-27
@@ -1,27 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "minecraft:jigsaw",
|
|
||||||
"biomes": "#cobblemon:has_structure/village_plains_pokecenter",
|
|
||||||
"max_distance_from_center": 80,
|
|
||||||
"project_start_to_heightmap": "WORLD_SURFACE_WG",
|
|
||||||
"size": 2,
|
|
||||||
"spawn_overrides": {
|
|
||||||
"creature": {
|
|
||||||
"bounding_box": "full",
|
|
||||||
"spawns": [
|
|
||||||
{
|
|
||||||
"type": "cobblemon:bulbasaur",
|
|
||||||
"weight": 100,
|
|
||||||
"minCount": 5,
|
|
||||||
"maxCount": 10
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"start_height": {
|
|
||||||
"absolute": 0
|
|
||||||
},
|
|
||||||
"start_pool": "cobblemon:village_plains_pokecenter/village_plains_pokecenter_pool",
|
|
||||||
"step": "surface_structures",
|
|
||||||
"terrain_adaptation": "beard_thin",
|
|
||||||
"use_expansion_hack": false
|
|
||||||
}
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "minecraft:jigsaw",
|
|
||||||
"biomes": "#cobblemon:has_structure/village_plains_pokecenter_signtest",
|
|
||||||
"max_distance_from_center": 80,
|
|
||||||
"project_start_to_heightmap": "WORLD_SURFACE_WG",
|
|
||||||
"size": 2,
|
|
||||||
"spawn_overrides": {},
|
|
||||||
"start_height": {
|
|
||||||
"absolute": 0
|
|
||||||
},
|
|
||||||
"start_pool": "cobblemon:village_plains_pokecenter_signtest/village_plains_pokecenter_signtest_pool",
|
|
||||||
"step": "surface_structures",
|
|
||||||
"terrain_adaptation": "beard_thin",
|
|
||||||
"use_expansion_hack": false
|
|
||||||
}
|
|
||||||
-14
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"placement": {
|
|
||||||
"type": "minecraft:random_spread",
|
|
||||||
"salt": 1642136474,
|
|
||||||
"separation": 8,
|
|
||||||
"spacing": 34
|
|
||||||
},
|
|
||||||
"structures": [
|
|
||||||
{
|
|
||||||
"structure": "cobblemon:village_plains_pokecenter",
|
|
||||||
"weight": 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
-14
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"placement": {
|
|
||||||
"type": "minecraft:random_spread",
|
|
||||||
"salt": 1642136475,
|
|
||||||
"separation": 8,
|
|
||||||
"spacing": 34
|
|
||||||
},
|
|
||||||
"structures": [
|
|
||||||
{
|
|
||||||
"structure": "cobblemon:village_plains_pokecenter_signtest",
|
|
||||||
"weight": 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "cobblemon:village_plains_pokecenter/village_plains_pokecenter_pool",
|
|
||||||
"fallback": "minecraft:empty",
|
|
||||||
"elements": [
|
|
||||||
{
|
|
||||||
"weight": 1,
|
|
||||||
"element": {
|
|
||||||
"location": "cobblemon:village_plains_pokecenter",
|
|
||||||
"processors": "minecraft:empty",
|
|
||||||
"projection": "rigid",
|
|
||||||
"element_type": "minecraft:single_pool_element"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "cobblemon:village_plains_pokecenter_signtest/village_plains_pokecenter_signtest_pool",
|
|
||||||
"fallback": "minecraft:empty",
|
|
||||||
"elements": [
|
|
||||||
{
|
|
||||||
"weight": 1,
|
|
||||||
"element": {
|
|
||||||
"location": "cobblemon:village_plains_pokecenter_signtest",
|
|
||||||
"processors": "minecraft:empty",
|
|
||||||
"projection": "rigid",
|
|
||||||
"element_type": "minecraft:single_pool_element"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,27 +1,18 @@
|
|||||||
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 {
|
|
||||||
plugins {
|
|
||||||
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,58 @@
|
|||||||
|
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()
|
||||||
|
}
|
||||||
|
|
||||||
|
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}")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+3
-6
@@ -1,9 +1,6 @@
|
|||||||
import utilities.VersionType
|
|
||||||
import utilities.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")
|
||||||
}
|
}
|
||||||
@@ -34,7 +31,7 @@ publishing {
|
|||||||
|
|
||||||
groupId = "com.cobblemon"
|
groupId = "com.cobblemon"
|
||||||
artifactId = project.findProperty("maven.artifactId")?.toString() ?: project.name
|
artifactId = project.findProperty("maven.artifactId")?.toString() ?: project.name
|
||||||
version = project.writeVersion(VersionType.PUBLISHING)
|
version = rootProject.version.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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"
|
||||||
+4
-6
@@ -1,14 +1,12 @@
|
|||||||
plugins {
|
plugins {
|
||||||
//id("cobblemon.root-conventions")
|
base
|
||||||
id ("net.nemerosa.versioning") version "3.1.0"
|
id("cobblemon.root-conventions")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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-SNAPSHOT"
|
||||||
version = "$version-${fixedBranchName}-${versioning.info.build}"
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
+29
-120
@@ -1,133 +1,42 @@
|
|||||||
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("com.cobblemon.gradle")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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/")
|
mavenLocal()
|
||||||
maven("https://maven.blamejared.com/")
|
|
||||||
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)
|
modApi(libs.molang)
|
||||||
compileOnly(libs.bundles.fabric.integrations.compileOnly) {
|
|
||||||
isTransitive = false
|
// For Showdown
|
||||||
}
|
modCompileOnly(libs.graal)
|
||||||
compileOnly("net.fabricmc:sponge-mixin:0.15.5+mixin.0.8.7")
|
|
||||||
compileOnly("io.github.llamalad7:mixinextras-fabric:0.4.1")
|
//shadowCommon group: 'commons-io', name: 'commons-io', version: '2.6'
|
||||||
testImplementation(libs.bundles.unitTesting)
|
|
||||||
|
|
||||||
|
testRuntimeOnly(libs.junitEngine)
|
||||||
|
testImplementation(libs.junitApi)
|
||||||
|
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 {
|
|
||||||
main {
|
|
||||||
blossom {
|
|
||||||
kotlinSources {
|
|
||||||
fun generateLicenseHeader() : String {
|
|
||||||
val builder = StringBuilder()
|
|
||||||
builder.append("/*\n")
|
|
||||||
project.projectDir.parentFile.resolve("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 as String)
|
|
||||||
property("isSnapshot", "true")
|
|
||||||
/*
|
|
||||||
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,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" ]
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* 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.access;
|
||||||
|
|
||||||
|
import net.minecraft.sound.SoundCategory;
|
||||||
|
|
||||||
|
public interface SoundManagerDuck {
|
||||||
|
void toggleCategories(SoundCategory... categories);
|
||||||
|
}
|
||||||
-16
@@ -1,16 +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.bridges;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
|
|
||||||
|
|
||||||
public interface StructureProcessorListBridge {
|
|
||||||
void append(StructureProcessor processor);
|
|
||||||
void clear();
|
|
||||||
}
|
|
||||||
+18
-10
@@ -8,9 +8,11 @@
|
|||||||
|
|
||||||
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 net.minecraft.client.render.VertexConsumer;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
import net.minecraft.entity.Entity;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,22 +38,28 @@ public interface Bone {
|
|||||||
/**
|
/**
|
||||||
* Renders a particular bone in relation to a particular entity.
|
* Renders a particular bone in relation to a particular entity.
|
||||||
*
|
*
|
||||||
* @param context The render context this bone is being drawn for.
|
* @param entity The entity this bone is being drawn for. This parameter need not be available and can be null
|
||||||
* @param stack The current [MatrixStack] for the renderer
|
* @param stack The current [MatrixStack] for the renderer
|
||||||
* @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(
|
<T extends Entity> void render(
|
||||||
RenderContext context,
|
@Nullable T entity,
|
||||||
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 +67,5 @@ public interface Bone {
|
|||||||
*
|
*
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
void transform(PoseStack matrixStack);
|
void transform(MatrixStack matrixStack);
|
||||||
}
|
}
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
@@ -1,20 +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 net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
public interface SoundManagerDuck {
|
|
||||||
|
|
||||||
void pauseSounds(@Nullable ResourceLocation id, @Nullable SoundSource category);
|
|
||||||
|
|
||||||
void resumeSounds(@Nullable ResourceLocation id, @Nullable SoundSource 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.CobblemonBuildDetails;
|
|
||||||
import net.minecraft.CrashReport;
|
|
||||||
import net.minecraft.CrashReportCategory;
|
|
||||||
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(CrashReport.class)
|
|
||||||
public final class CrashReportMixin {
|
|
||||||
|
|
||||||
@Inject(method = "getDetails(Ljava/lang/StringBuilder;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/SystemReport;appendToCrashReportString(Ljava/lang/StringBuilder;)V"))
|
|
||||||
public void cobblemon$printCobblemonDetails(StringBuilder builder, CallbackInfo callback) {
|
|
||||||
CrashReportCategory cobblemon = new CrashReportCategory("Cobblemon");
|
|
||||||
cobblemon.setDetail("Version", CobblemonBuildDetails.VERSION);
|
|
||||||
cobblemon.setDetail("Is Snapshot", CobblemonBuildDetails.SNAPSHOT);
|
|
||||||
cobblemon.setDetail("Git Commit", CobblemonBuildDetails.INSTANCE.smallCommitHash() + " (" + "https://gitlab.com/cable-mc/cobblemon/-/commit/" + CobblemonBuildDetails.GIT_COMMIT + ")");
|
|
||||||
cobblemon.setDetail("Branch", CobblemonBuildDetails.BRANCH);
|
|
||||||
|
|
||||||
cobblemon.getDetails(builder);
|
|
||||||
builder.append("\n\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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.sherds.CobblemonSherds;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.level.block.entity.DecoratedPotPattern;
|
|
||||||
import net.minecraft.world.level.block.entity.DecoratedPotPatterns;
|
|
||||||
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(DecoratedPotPatterns.class)
|
|
||||||
public abstract class DecoratedPotPatternsMixin {
|
|
||||||
@Inject(method = "getPatternFromItem", at=@At("HEAD"), cancellable = true)
|
|
||||||
private static void cobblemon$getCobblemonSherdTexture(
|
|
||||||
Item sherd,
|
|
||||||
CallbackInfoReturnable<ResourceKey<DecoratedPotPattern>> cir
|
|
||||||
) {
|
|
||||||
if (CobblemonSherds.INSTANCE.getSherdToPattern().containsKey(sherd)) {
|
|
||||||
cir.setReturnValue(CobblemonSherds.INSTANCE.getSherdToPattern().get(sherd));
|
|
||||||
cir.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+7
-57
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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 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 com.cobblemon.mod.common.villager.VillagerGatherableItems;
|
|
||||||
|
|
||||||
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)
|
|
||||||
public abstract class EntityVillagerMixin {
|
|
||||||
|
|
||||||
@Inject(method = "wantsToPickUp", at = @At(value = "RETURN"), cancellable = true)
|
|
||||||
private void cobblemon$canGather(ItemStack stack, CallbackInfoReturnable<Boolean> ci) {
|
|
||||||
final Villager villager = (Villager) (Object) this;
|
|
||||||
if(ci.getReturnValue() == false && Objects.equals(villager.getVillagerData().getProfession(), VillagerProfession.FARMER) && villager.getInventory().canAddItem(stack)) {
|
|
||||||
if(VillagerGatherableItems.INSTANCE.getVillagerGatherableItems().contains(stack.getItem()))
|
|
||||||
ci.setReturnValue(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +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.PreEmptsExplosion;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.world.level.Explosion;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
|
|
||||||
@Mixin(value = Explosion.class)
|
|
||||||
public class ExplosionMixin {
|
|
||||||
|
|
||||||
@Redirect(
|
|
||||||
method = "finalizeExplosion",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "Lnet/minecraft/world/level/Level;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;",
|
|
||||||
ordinal = 0
|
|
||||||
)
|
|
||||||
)
|
|
||||||
public BlockState cobblemon$whenExploded(Level world, BlockPos pos) {
|
|
||||||
BlockState blockState = world.getBlockState(pos);
|
|
||||||
if(blockState.getBlock() instanceof PreEmptsExplosion preExplosionBlock) {
|
|
||||||
preExplosionBlock.whenExploded(world, blockState, pos);
|
|
||||||
}
|
|
||||||
return blockState;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* 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.CobblemonBlocks;
|
||||||
|
import com.cobblemon.mod.common.block.PastureBlock;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.FenceBlock;
|
||||||
|
import net.minecraft.block.HorizontalFacingBlock;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(value = FenceBlock.class)
|
||||||
|
public abstract class FenceBlockMixin {
|
||||||
|
|
||||||
|
// This could be done with a modify variable but it just doesn't seem to want to work, very crude unfinished explanation I had on Fabric discord was
|
||||||
|
// "boolean is a primitive, it isnt passed by reference but by value and you have your own object references anyway so assigning a new object to non-primitive references (variables) wont modify it after your mixin returns
|
||||||
|
//(you cant modify a random argument that mixin passes you that way, target the boolean not the FenceBlock)"
|
||||||
|
// However the issue is the only way to get all the params which we need is by passing in the entire method reference which enforces the return type.
|
||||||
|
|
||||||
|
@Redirect(method = "getStateForNeighborUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/FenceBlock;canConnect(Lnet/minecraft/block/BlockState;ZLnet/minecraft/util/math/Direction;)Z"))
|
||||||
|
private boolean cobblemon$getStateForNeighborUpdate(FenceBlock instance, BlockState state, boolean neighborIsFullSquare, Direction dir) {
|
||||||
|
return instance.canConnect(state, neighborIsFullSquare, dir) || this.cobblemon$canConnect(state, dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "getPlacementState", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/FenceBlock;canConnect(Lnet/minecraft/block/BlockState;ZLnet/minecraft/util/math/Direction;)Z"))
|
||||||
|
private boolean cobblemon$getPlacementState(FenceBlock instance, BlockState state, boolean neighborIsFullSquare, Direction dir) {
|
||||||
|
return instance.canConnect(state, neighborIsFullSquare, dir) || this.cobblemon$canConnect(state, dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean cobblemon$canConnect(BlockState state, Direction dir) {
|
||||||
|
if (state.isOf(CobblemonBlocks.PASTURE) && state.get(PastureBlock.Companion.getPART()) == PastureBlock.PasturePart.BOTTOM) {
|
||||||
|
final Direction pastureFacing = state.get(HorizontalFacingBlock.FACING);
|
||||||
|
return dir == pastureFacing.rotateYClockwise() || dir == pastureFacing.rotateYCounterclockwise();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,38 +8,20 @@
|
|||||||
|
|
||||||
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.ScheduledTaskTracker;
|
||||||
import net.minecraft.client.DeltaTracker;
|
import net.minecraft.client.render.GameRenderer;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
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.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(GameRenderer.class)
|
@Mixin(GameRenderer.class)
|
||||||
public class GameRendererMixin {
|
public class GameRendererMixin {
|
||||||
@Unique
|
|
||||||
long lastTime = -1;
|
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
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();
|
ScheduledTaskTracker.INSTANCE.update();
|
||||||
long newTime = System.currentTimeMillis();
|
|
||||||
// Don't play scheduled animations when the game is paused
|
|
||||||
if (client.isPaused()) {
|
|
||||||
lastTime = newTime;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lastTime != -1) {
|
|
||||||
ClientTaskTracker.INSTANCE.update((newTime - lastTime) / 1000F);
|
|
||||||
}
|
|
||||||
lastTime = newTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.mixin;
|
|
||||||
|
|
||||||
import com.cobblemon.mod.common.client.CobblemonBakingOverrides;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import net.minecraft.client.color.block.BlockColors;
|
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
|
||||||
import net.minecraft.client.resources.model.BlockStateModelLoader;
|
|
||||||
import net.minecraft.client.resources.model.ModelBakery;
|
|
||||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
|
||||||
import net.minecraft.client.resources.model.UnbakedModel;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.util.profiling.ProfilerFiller;
|
|
||||||
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(ModelBakery.class)
|
|
||||||
public abstract class ModelLoaderMixin {
|
|
||||||
|
|
||||||
@Shadow abstract UnbakedModel getModel(ResourceLocation resourceLocation);
|
|
||||||
|
|
||||||
@Shadow protected abstract void registerModel(ModelResourceLocation modelId, UnbakedModel unbakedModel);
|
|
||||||
|
|
||||||
@Inject(
|
|
||||||
method = "<init>",
|
|
||||||
at = @At("TAIL")
|
|
||||||
)
|
|
||||||
public void init(BlockColors blockColors,
|
|
||||||
ProfilerFiller profiler,
|
|
||||||
Map<ResourceLocation, BlockModel> jsonUnbakedModels,
|
|
||||||
Map<ResourceLocation, List<BlockStateModelLoader.LoadedJson>> blockStates,
|
|
||||||
CallbackInfo ci) {
|
|
||||||
CobblemonBakingOverrides.INSTANCE.getModels().forEach(bakingOverride -> {
|
|
||||||
var unbakedModel = this.getModel(bakingOverride.getModelLocation());
|
|
||||||
this.registerModel(bakingOverride.getModelIdentifier(), unbakedModel);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,22 +9,22 @@
|
|||||||
package com.cobblemon.mod.common.mixin;
|
package com.cobblemon.mod.common.mixin;
|
||||||
|
|
||||||
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 net.minecraft.client.model.ModelPart;
|
||||||
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 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 +36,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 <T extends Entity> void render(T entity, 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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.api.snowstorm.ParticleMaterials;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import org.spongepowered.asm.mixin.Final;
|
|
||||||
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.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import net.minecraft.client.particle.ParticleEngine;
|
|
||||||
import net.minecraft.client.particle.ParticleRenderType;
|
|
||||||
|
|
||||||
@Mixin(ParticleEngine.class)
|
|
||||||
final class ParticleManagerMixin {
|
|
||||||
@Mutable
|
|
||||||
@Final
|
|
||||||
@Shadow
|
|
||||||
private static List<ParticleRenderType> RENDER_ORDER;
|
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "<clinit>")
|
|
||||||
private static void lodestone$addTypes(CallbackInfo ci) {
|
|
||||||
RENDER_ORDER = ImmutableList.<ParticleRenderType>builder().addAll(RENDER_ORDER)
|
|
||||||
.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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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.CobblemonItems;
|
|
||||||
import net.minecraft.world.entity.monster.piglin.PiglinAi;
|
|
||||||
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(PiglinAi.class)
|
|
||||||
public class PiglinBarterMixin {
|
|
||||||
|
|
||||||
@Inject(method = "isBarterCurrency", at = @At(value = "RETURN"), cancellable = true)
|
|
||||||
private static void cobblemon$acceptsForBarter(ItemStack stack, CallbackInfoReturnable<Boolean> ci) {
|
|
||||||
if(!ci.getReturnValue()) {
|
|
||||||
//TODO: Make a tag?
|
|
||||||
if(stack.is(CobblemonItems.RELIC_COIN_POUCH))
|
|
||||||
ci.setReturnValue(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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.CobblemonItems;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
|
||||||
import net.minecraft.world.entity.monster.piglin.Piglin;
|
|
||||||
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(Piglin.class)
|
|
||||||
public abstract class PiglinEntityMixin {
|
|
||||||
@Inject(method = "holdInOffHand", at = @At(value = "HEAD"), cancellable = true)
|
|
||||||
public void cobblemon$isValidBarteringItem(ItemStack stack, CallbackInfo ci) {
|
|
||||||
Piglin entity = (Piglin)(Object) this;
|
|
||||||
if (stack.is(CobblemonItems.RELIC_COIN_POUCH)) {
|
|
||||||
entity.setItemSlot(EquipmentSlot.OFFHAND, stack);
|
|
||||||
entity.setGuaranteedDrop(EquipmentSlot.OFFHAND);
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -12,88 +12,76 @@ 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.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.item.Items;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.sound.SoundEvent;
|
||||||
import net.minecraft.world.entity.item.ItemEntity;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.world.food.FoodProperties;
|
import net.minecraft.world.World;
|
||||||
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)
|
import static com.cobblemon.mod.common.util.LocalizationUtilsKt.lang;
|
||||||
public abstract class PlayerMixin extends LivingEntity implements ScannableEntity {
|
|
||||||
|
|
||||||
@Shadow public abstract CompoundTag getShoulderEntityLeft();
|
@Mixin(PlayerEntity.class)
|
||||||
|
public abstract class PlayerMixin extends LivingEntity {
|
||||||
|
|
||||||
@Shadow public abstract CompoundTag getShoulderEntityRight();
|
@Shadow public abstract NbtCompound getShoulderEntityLeft();
|
||||||
|
|
||||||
@Shadow public abstract void respawnEntityOnShoulder(CompoundTag entityNbt);
|
@Shadow public abstract NbtCompound getShoulderEntityRight();
|
||||||
|
|
||||||
@Shadow public abstract void setShoulderEntityRight(CompoundTag entityNbt);
|
@Shadow public abstract void dropShoulderEntity(NbtCompound entityNbt);
|
||||||
|
|
||||||
@Shadow public abstract void setShoulderEntityLeft(CompoundTag entityNbt);
|
@Shadow public abstract void setShoulderEntityRight(NbtCompound 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 +89,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 +100,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.getItem() == Items.APPLE && 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 +162,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* 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.brewing.BrewingRecipes;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.screen.BrewingStandScreenHandler;
|
||||||
|
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(BrewingStandScreenHandler.PotionSlot.class)
|
||||||
|
public class PotionSlotMixin {
|
||||||
|
@Inject(
|
||||||
|
method = "matches",
|
||||||
|
at = @At(value = "HEAD"),
|
||||||
|
cancellable = true
|
||||||
|
)
|
||||||
|
private static void matchesBrewable(ItemStack stack, CallbackInfoReturnable<Boolean> cir) {
|
||||||
|
if (BrewingRecipes.brewableItems.contains(stack.getItem())) {
|
||||||
|
cir.setReturnValue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* 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.api.spawning.mixins.CachedOnlyChunkAccessor;
|
||||||
|
import com.mojang.datafixers.util.Either;
|
||||||
|
import net.minecraft.server.world.ChunkHolder;
|
||||||
|
import net.minecraft.server.world.ServerChunkManager;
|
||||||
|
import net.minecraft.util.math.ChunkPos;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
import net.minecraft.world.chunk.ChunkManager;
|
||||||
|
import net.minecraft.world.chunk.ChunkStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Mixin(ServerChunkManager.class)
|
||||||
|
public abstract class ServerChunkManagerMixin extends ChunkManager implements CachedOnlyChunkAccessor {
|
||||||
|
@Shadow @Nullable protected abstract ChunkHolder getChunkHolder(long pos);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Chunk cobblemon$request(int x, int z, @NotNull ChunkStatus status) {
|
||||||
|
long l = ChunkPos.toLong(x, z);
|
||||||
|
|
||||||
|
ChunkHolder holder = getChunkHolder(l);
|
||||||
|
if (holder != null) {
|
||||||
|
CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>> future = holder.getFutureFor(status);
|
||||||
|
if (future.isDone()) {
|
||||||
|
return future.join().left().orElse(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
+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,90 +8,36 @@
|
|||||||
|
|
||||||
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.access.SoundManagerDuck;
|
||||||
import com.cobblemon.mod.common.client.sound.EntitySoundTracker;
|
import net.minecraft.client.sound.SoundInstance;
|
||||||
import com.cobblemon.mod.common.client.sound.BattleMusicController;
|
import net.minecraft.client.sound.SoundManager;
|
||||||
import com.cobblemon.mod.common.client.sound.SoundTracker;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import com.cobblemon.mod.common.duck.SoundManagerDuck;
|
|
||||||
import com.cobblemon.mod.common.duck.SoundEngineDuck;
|
|
||||||
import net.minecraft.client.resources.sounds.BiomeAmbientSoundsHandler;
|
|
||||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
|
||||||
import net.minecraft.client.resources.sounds.UnderwaterAmbientSoundInstances;
|
|
||||||
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.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.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(SoundManager.class)
|
@Mixin(SoundManager.class)
|
||||||
public abstract class SoundManagerMixin implements SoundManagerDuck {
|
public class SoundManagerMixin implements SoundManagerDuck {
|
||||||
|
|
||||||
@Shadow
|
private boolean[] blockedCategories = new boolean[SoundCategory.values().length];
|
||||||
public abstract boolean isActive(SoundInstance sound);
|
|
||||||
|
|
||||||
@Shadow @Final
|
|
||||||
private SoundEngine soundEngine;
|
|
||||||
|
|
||||||
// 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) {
|
|
||||||
return sound instanceof BiomeAmbientSoundsHandler.LoopSoundInstance || sound instanceof UnderwaterAmbientSoundInstances.UnderwaterAmbientSoundInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean filterCondition(SoundInstance sound) {
|
|
||||||
return !isAmbientLoop(sound) &&
|
|
||||||
this.isActive(BattleMusicController.INSTANCE.getMusic()) &&
|
|
||||||
BattleMusicController.INSTANCE.getFilteredCategories().contains(sound.getSource());
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean ambientLoopCondition(SoundInstance sound) {
|
|
||||||
return isAmbientLoop(sound) &&
|
|
||||||
this.isActive(BattleMusicController.INSTANCE.getMusic()) &&
|
|
||||||
BattleMusicController.INSTANCE.getFilteredCategories().contains(sound.getSource());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 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 toggleCategories(SoundCategory... categories) {
|
||||||
((SoundEngineDuck)soundEngine).pauseSounds(id, category);
|
for (SoundCategory category : categories) {
|
||||||
|
int index = category.ordinal();
|
||||||
|
boolean blocked = blockedCategories[index];
|
||||||
|
blockedCategories[index] = !blocked;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resumes the queried SoundInstance(s). If id is null, will resume all sounds belonging to the SoundCategory. */
|
@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V", at = @At("HEAD"), cancellable = true)
|
||||||
@Override
|
public void play(SoundInstance sound, CallbackInfo cb) {
|
||||||
public void resumeSounds(@Nullable ResourceLocation id, @Nullable SoundSource category) {
|
if (blockedCategories[sound.getCategory().ordinal()]) cb.cancel();
|
||||||
((SoundEngineDuck)soundEngine).resumeSounds(id, category);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Blocks filtered sounds from being played while a BattleMusicInstance is in progress. */
|
@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;I)V", at = @At("HEAD"), cancellable = true)
|
||||||
@Inject(method = "play(Lnet/minecraft/client/resources/sounds/SoundInstance;)V", at = @At("HEAD"), cancellable = true)
|
public void play(SoundInstance sound, int delay, CallbackInfo cb) {
|
||||||
public void playStart(SoundInstance sound, CallbackInfo cb) {
|
if (blockedCategories[sound.getCategory().ordinal()]) cb.cancel();
|
||||||
if (filterCondition(sound)) cb.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "playDelayed(Lnet/minecraft/client/resources/sounds/SoundInstance;I)V", at = @At("HEAD"), cancellable = true)
|
|
||||||
public void playStart(SoundInstance sound, int delay, CallbackInfo cb) {
|
|
||||||
if (filterCondition(sound)) cb.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Pauses ambient loops while a BattleMusicInstance is in progress. */
|
|
||||||
@Inject(method = "play(Lnet/minecraft/client/resources/sounds/SoundInstance;)V", at = @At("TAIL"))
|
|
||||||
public void playEnd(SoundInstance sound, CallbackInfo cb) {
|
|
||||||
if (ambientLoopCondition(sound)) this.pauseSounds(sound.getLocation(), SoundSource.AMBIENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "playDelayed(Lnet/minecraft/client/resources/sounds/SoundInstance;I)V", at = @At("TAIL"))
|
|
||||||
public void playEnd(SoundInstance sound, int delay, CallbackInfo cb) {
|
|
||||||
if (ambientLoopCondition(sound)) this.pauseSounds(sound.getLocation(), SoundSource.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,39 @@
|
|||||||
|
/*
|
||||||
|
* 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.google.common.collect.Multimap;
|
||||||
|
import net.minecraft.client.sound.SoundInstance;
|
||||||
|
import net.minecraft.client.sound.SoundSystem;
|
||||||
|
import net.minecraft.sound.SoundCategory;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
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(SoundSystem.class)
|
||||||
|
public abstract class SoundSystemMixin {
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
private Multimap<SoundCategory, SoundInstance> sounds;
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
protected abstract void stop(SoundInstance sound);
|
||||||
|
|
||||||
|
@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) {
|
||||||
|
sounds.get(category).forEach(this::stop);
|
||||||
|
cb.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,32 +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.mojang.datafixers.util.Pair;
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Mutable;
|
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
|
||||||
|
|
||||||
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)
|
|
||||||
public interface StructurePoolAccessor {
|
|
||||||
@Accessor("rawTemplates")
|
|
||||||
List<Pair<StructurePoolElement, Integer>> getElementCounts();
|
|
||||||
|
|
||||||
@Mutable
|
|
||||||
@Accessor("rawTemplates")
|
|
||||||
void setElementCounts(List<Pair<StructurePoolElement, Integer>> elementCounts);
|
|
||||||
|
|
||||||
@Accessor("templates")
|
|
||||||
ObjectArrayList<StructurePoolElement> getElements();
|
|
||||||
}
|
|
||||||
@@ -1,165 +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.world.CobblemonStructureIDs;
|
|
||||||
import com.llamalad7.mixinextras.sugar.Local;
|
|
||||||
import net.minecraft.core.Registry;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.util.RandomSource;
|
|
||||||
import net.minecraft.world.level.LevelHeightAccessor;
|
|
||||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
|
||||||
import net.minecraft.world.level.levelgen.RandomState;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.PoolElementStructurePiece;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.pools.*;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.pools.alias.PoolAliasLookup;
|
|
||||||
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.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.CallbackInfo;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@Mixin(JigsawPlacement.Placer.class)
|
|
||||||
public abstract class StructurePoolGeneratorMixin {
|
|
||||||
|
|
||||||
Map<String, Integer> generatedStructureGroupCounts;
|
|
||||||
|
|
||||||
private static final Map<String, Integer> structureMaxes;
|
|
||||||
private static final Map<ResourceLocation, Set<String>> structureGroups = new HashMap<>();
|
|
||||||
static {
|
|
||||||
String pokecenter = "pokecenter";
|
|
||||||
String berry = "berry_farm";
|
|
||||||
|
|
||||||
structureGroups.put(CobblemonStructureIDs.VILLAGE_PLAINS_POKECENTER, Set.of(pokecenter));
|
|
||||||
structureGroups.put(CobblemonStructureIDs.VILLAGE_DESERT_POKECENTER, Set.of(pokecenter));
|
|
||||||
structureGroups.put(CobblemonStructureIDs.VILLAGE_SAVANNA_POKECENTER, Set.of(pokecenter));
|
|
||||||
structureGroups.put(CobblemonStructureIDs.VILLAGE_SNOWY_POKECENTER, Set.of(pokecenter));
|
|
||||||
structureGroups.put(CobblemonStructureIDs.VILLAGE_TAIGA_POKECENTER, Set.of(pokecenter));
|
|
||||||
|
|
||||||
structureGroups.put(CobblemonStructureIDs.SAVANNA_BERRY_SMALL, Set.of(berry));
|
|
||||||
structureGroups.put(CobblemonStructureIDs.SAVANNA_BERRY_LARGE, Set.of(berry));
|
|
||||||
structureGroups.put(CobblemonStructureIDs.PLAINS_BERRY_SMALL, Set.of(berry));
|
|
||||||
structureGroups.put(CobblemonStructureIDs.PLAINS_BERRY_LARGE, Set.of(berry));
|
|
||||||
structureGroups.put(CobblemonStructureIDs.SNOWY_BERRY_SMALL, Set.of(berry));
|
|
||||||
structureGroups.put(CobblemonStructureIDs.SNOWY_BERRY_LARGE, Set.of(berry));
|
|
||||||
structureGroups.put(CobblemonStructureIDs.DESERT_BERRY_SMALL, Set.of(berry));
|
|
||||||
structureGroups.put(CobblemonStructureIDs.DESERT_BERRY_LARGE, Set.of(berry));
|
|
||||||
structureGroups.put(CobblemonStructureIDs.TAIGA_BERRY_SMALL, Set.of(berry));
|
|
||||||
structureGroups.put(CobblemonStructureIDs.TAIGA_BERRY_LARGE, Set.of(berry));
|
|
||||||
|
|
||||||
//Mapped using location string as key
|
|
||||||
Map<String, Integer> aMap = new HashMap<>();
|
|
||||||
aMap.put(pokecenter, 1);
|
|
||||||
aMap.put(berry, 2);
|
|
||||||
|
|
||||||
// aMap.put(CobblemonStructureIDs.PLAINS_LONG_PATH, 3);
|
|
||||||
// aMap.put(CobblemonStructureIDs.DESERT_LONG_PATH, 3);
|
|
||||||
// aMap.put(CobblemonStructureIDs.SAVANNA_LONG_PATH, 3);
|
|
||||||
// aMap.put(CobblemonStructureIDs.SNOWY_LONG_PATH, 3);
|
|
||||||
// aMap.put(CobblemonStructureIDs.TAIGA_LONG_PATH, 3);
|
|
||||||
structureMaxes = Collections.unmodifiableMap(aMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getGroups(ResourceLocation structureIdentifier) {
|
|
||||||
return structureGroups.getOrDefault(structureIdentifier, Set.of());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasReachedMaximum(ResourceLocation structureIdentifier) {
|
|
||||||
Set<String> groups = getGroups(structureIdentifier);
|
|
||||||
for (String group : groups) {
|
|
||||||
int count = generatedStructureGroupCounts.getOrDefault(group, 0);
|
|
||||||
if (count >= structureMaxes.getOrDefault(group, Integer.MAX_VALUE)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void incrementStructureCount(ResourceLocation structureIdentifier) {
|
|
||||||
Set<String> groups = getGroups(structureIdentifier);
|
|
||||||
for (String group : groups) {
|
|
||||||
generatedStructureGroupCounts.put(group, generatedStructureGroupCounts.getOrDefault(group, 0) + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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) {
|
|
||||||
generatedStructureGroupCounts = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ModifyVariable(method = "tryPlacingChildren", at = @At("STORE"), ordinal = 1)
|
|
||||||
private Iterator<StructurePoolElement> reduceStructurePoolElementIterator(Iterator<StructurePoolElement> iterator) {
|
|
||||||
List<StructurePoolElement> reducedList = new ArrayList<>();
|
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
StructurePoolElement structure = iterator.next();
|
|
||||||
ResourceLocation structurePieceLocationKey = getCobblemonOnlyLocation(structure);
|
|
||||||
if (structurePieceLocationKey == null) {
|
|
||||||
reducedList.add(structure);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasReachedMaximum(structurePieceLocationKey)) {
|
|
||||||
reducedList.add(structure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return reducedList.iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "tryPlacingChildren", at = @At(value = "NEW", target = "net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
|
|
||||||
private void afterTryPlacingChildren(
|
|
||||||
PoolElementStructurePiece poolElementStructurePiece,
|
|
||||||
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) {
|
|
||||||
incrementStructureCount(structureLocationKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ResourceLocation getCobblemonOnlyLocation(StructurePoolElement structurePoolElement) {
|
|
||||||
ResourceLocation location = getLocationIfAvailable(structurePoolElement);
|
|
||||||
if (location == null) return null;
|
|
||||||
|
|
||||||
if (!location.getNamespace().equals("cobblemon")) return null;
|
|
||||||
|
|
||||||
return location;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ResourceLocation getLocationIfAvailable(StructurePoolElement structurePoolElement) {
|
|
||||||
if (structurePoolElement instanceof LegacySinglePoolElement legacySinglePoolElement) {
|
|
||||||
if (legacySinglePoolElement.template.left().isEmpty()) return null;
|
|
||||||
|
|
||||||
return legacySinglePoolElement.template.left().get();
|
|
||||||
} else if (structurePoolElement instanceof SinglePoolElement singlePoolElement) {
|
|
||||||
if (singlePoolElement.template.left().isEmpty()) return null;
|
|
||||||
|
|
||||||
return singlePoolElement.template.left().get();
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +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.bridges.StructureProcessorListBridge;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList;
|
|
||||||
import org.spongepowered.asm.mixin.Final;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Mutable;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
|
|
||||||
@Mixin(StructureProcessorList.class)
|
|
||||||
public class StructureProcessorListMixin implements StructureProcessorListBridge {
|
|
||||||
|
|
||||||
@Final
|
|
||||||
@Mutable
|
|
||||||
@Shadow
|
|
||||||
private List<StructureProcessor> list;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void append(StructureProcessor processor) {
|
|
||||||
List<StructureProcessor> mutable = new ArrayList<>(this.list);
|
|
||||||
mutable.add(processor);
|
|
||||||
this.list = ImmutableList.copyOf(mutable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear() {
|
|
||||||
this.list = ImmutableList.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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();
|
|
||||||
}
|
|
||||||
@@ -1,23 +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.entity.vehicle.Boat;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
|
||||||
|
|
||||||
@Mixin(Boat.class)
|
|
||||||
public interface BoatEntityAccessor {
|
|
||||||
|
|
||||||
@Accessor("lastYd")
|
|
||||||
void setFallVelocity(double fallVelocity);
|
|
||||||
|
|
||||||
@Accessor("status")
|
|
||||||
Boat.Status 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();
|
||||||
|
|
||||||
}
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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.sound.MusicTracker;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
@Mixin(MusicTracker.class)
|
||||||
|
public interface MusicTrackerAccessor {
|
||||||
|
@Accessor("timeUntilNextSong")
|
||||||
|
int timeUntilNextSong();
|
||||||
|
|
||||||
|
@Accessor("timeUntilNextSong")
|
||||||
|
void setTimeUntilNextSong(int timeUntilNextSong);
|
||||||
|
}
|
||||||
+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,23 +18,23 @@ 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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.invoker;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.FireBlock;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
|
||||||
|
|
||||||
@Mixin(FireBlock.class)
|
|
||||||
public interface FireBlockInvoker {
|
|
||||||
@Invoker("setFlammable") void registerNewFlammableBlock(Block block, int burnChance, int spreadChance);
|
|
||||||
}
|
|
||||||
+5
-4
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+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.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;
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
{{ license }}
|
|
||||||
|
|
||||||
package com.cobblemon.mod.common
|
|
||||||
|
|
||||||
object CobblemonBuildDetails {
|
|
||||||
|
|
||||||
const val MOD_ID = "{{ modid }}"
|
|
||||||
const val VERSION = "{{ version }}"
|
|
||||||
const val SNAPSHOT = {{ isSnapshot }}
|
|
||||||
|
|
||||||
const val GIT_COMMIT = "{{ gitCommit | default("Not Specified") }}"
|
|
||||||
const val BRANCH = "{{ branch | default("Not Specified") }}"
|
|
||||||
|
|
||||||
fun smallCommitHash(): String {
|
|
||||||
return this.GIT_COMMIT.substring(0, 7)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loaded 100 of 18244 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user