diff --git a/.github/workflows/fabric-build.yml b/.github/workflows/fabric-build.yml index ef9f6bf46..17426e701 100644 --- a/.github/workflows/fabric-build.yml +++ b/.github/workflows/fabric-build.yml @@ -30,7 +30,7 @@ jobs: - name: make gradle wrapper executable run: chmod +x ./gradlew - name: build - run: ./gradlew fabric:build + run: ./gradlew build - name: capture build artifacts uses: actions/upload-artifact@v2 with: diff --git a/.github/workflows/fabric-release.yml b/.github/workflows/fabric-release.yml index 2582c9d3c..eda61f9d7 100644 --- a/.github/workflows/fabric-release.yml +++ b/.github/workflows/fabric-release.yml @@ -32,16 +32,16 @@ jobs: run: chmod +x gradlew - name: Build with Gradle - run: ./gradlew fabric:build --stacktrace + run: ./gradlew :build --stacktrace - name: Upload GitHub release uses: AButler/upload-release-assets@v2.0 with: - files: "fabric/build/libs/*.jar" + files: 'build/libs/*.jar' repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Publish with Gradle - run: ./gradlew fabric:modrinth fabric:curseforge --stacktrace + run: ./gradlew modrinth curseforge --stacktrace env: CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} diff --git a/.gitignore b/.gitignore index f66fe20ee..c476faf29 100644 --- a/.gitignore +++ b/.gitignore @@ -32,5 +32,9 @@ bin/ run/ -# Architectury -.architectury-transformer +# java + +hs_err_*.log +replay_*.log +*.hprof +*.jfr diff --git a/build.gradle b/build.gradle index f3b311c33..9f4213a44 100644 --- a/build.gradle +++ b/build.gradle @@ -1,141 +1,168 @@ plugins { - // Fabric loom - id "fabric-loom" version "1.1-SNAPSHOT" apply false - // Forge Gradle - id 'net.minecraftforge.gradle' version '6.0.+' apply false + id 'fabric-loom' version '1.7-SNAPSHOT' + id 'maven-publish' - id 'com.matthewprenger.cursegradle' version '1.4.0' apply false - id "com.modrinth.minotaur" version "2.+" apply false + id 'com.matthewprenger.cursegradle' version '1.4.0' + id "com.modrinth.minotaur" version "2.+" +} + +version = project.mod_version +group = project.maven_group + +base { + archivesName = project.archives_base_name } repositories { - mavenCentral() - maven { - url 'https://jitpack.io' - } - maven { url "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven" } + maven { url 'https://maven.nucleoid.xyz' } + maven { + url 'https://masa.dy.fi/maven' + } + maven { url 'https://jitpack.io' } } -allprojects { - apply plugin: "java" - apply plugin: "maven-publish" - - archivesBaseName = rootProject.archives_base_name + "-" + project.name + "-" + rootProject.minecraft_version - version = rootProject.mod_version - group = rootProject.maven_group - - repositories { - mavenCentral() - maven { - url 'https://jitpack.io' - } - maven { url 'https://maven.nucleoid.xyz' } - } - - tasks.withType(JavaCompile).configureEach { - it.options.encoding = "UTF-8" - - def javaTarget = 17 - it.options.release = javaTarget - - sourceCompatibility = JavaVersion.toVersion(javaTarget) - targetCompatibility = JavaVersion.toVersion(javaTarget) - - if (JavaVersion.current() < JavaVersion.toVersion(javaTarget)) { - toolchain.languageVersion.set(JavaLanguageVersion.of(javaTarget)) - } - } - - publishing { - publications { - mavenJava(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - // Notice: This block does NOT have the same function as the block in the top level. - // The repositories here will be used for publishing your artifact, not for - // retrieving dependencies. - mavenLocal() - } - } +loom { + splitEnvironmentSourceSets() + + mods { + "taterzens" { + sourceSet sourceSets.main + sourceSet sourceSets.client + } + } + } -subprojects { - - // Publishing plugins - if (it.name != "common") { - apply plugin: "com.modrinth.minotaur" - apply plugin: "com.matthewprenger.cursegradle" - } - - if (it.name != "forge") { - apply plugin: "fabric-loom" - repositories { - maven { - url 'https://oss.sonatype.org/content/repositories/snapshots' - } - maven { - url 'https://masa.dy.fi/maven' - } - } - - loom { - accessWidenerPath = file("${project.rootDir}/common/src/main/resources/taterzens.accesswidener") - } - - dependencies { - // To change the versions see the gradle.properties file - modImplementation "net.fabricmc:fabric-loader:${rootProject.loader_version}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_version}" - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings loom.layered { - //mappings("net.fabricmc:yarn:$project.yarn_mappings:v2") - it.officialMojangMappings() - } - - // C2B - modImplementation("com.github.samolego.Config2Brigadier:config2brigadier-fabric:${rootProject.c2b_version}") - - - // Disguiselib - modImplementation("xyz.nucleoid:disguiselib-fabric:${project.disguiselib_version}") - } - } - - if (it.name != "common") { - dependencies { - compileOnly project(":common") - } - - processResources { - from project(":common").sourceSets.main.resources - } - - tasks.withType(JavaCompile) { - source(project(":common").sourceSets.main.allSource) - } - } - - jar { - from("LICENSE") { - rename { "${it}_${project.archivesBaseName}" } - } - manifest { - attributes([ - "Specification-Title" : rootProject.archives_base_name, - "Specification-Vendor" : "", - "Specification-Version" : rootProject.mod_version, - "Implementation-Title" : project.name, - "Implementation-Version" : project.jar.archiveVersion, - "Implementation-Vendor" : "", - "MixinConfigs" : "${rootProject.archives_base_name}.mixins.json", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") - ]) - } - } +dependencies { + // To change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings loom.layered { + //mappings("net.fabricmc:yarn:$project.yarn_mappings:v2") + it.officialMojangMappings() + } + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + + // Mod Dependencies + + // Carpet Mod + modCompileOnly("com.github.gnembon:fabric-carpet:${project.carpet_core_version}") + + // Disguiselib + // Commented out of main codebase for now, as TYPE change is achieved by Poylmer + //modCompileOnly("xyz.nucleoid:disguiselib-fabric:${project.disguiselib_version}") + //modImplementation(include('com.github.NucleoidMC:DisguiseLib:90bf223196')) + + // Permission API + modImplementation(include('me.lucko:fabric-permissions-api:0.1-SNAPSHOT')) + + // Server translations + // Commented out for now until we can confirm the 1.21 supported version. Does not impact general mod function + //modImplementation(include("xyz.nucleoid:server-translations-api:${project.translations_api}")) + + // SGUI + modImplementation(include("eu.pb4:sgui:${project.sgui_version}")) + + // C2B + modImplementation(include("com.github.samolego.Config2Brigadier:config2brigadier-fabric:${project.c2b_version}")) + + // Polymer + modImplementation(include("eu.pb4:polymer-core:${project.polymer_version}")) + +} + +processResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": project.version + } +} + +tasks.withType(JavaCompile).configureEach { + // One of the big changes to 1.21 is a requirement for at least Java 21, using 22 as it's current at time of dev. + it.options.release = 22 +} + +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() + + sourceCompatibility = JavaVersion.VERSION_22 + targetCompatibility = JavaVersion.VERSION_22 +} + +jar { + from("LICENSE") { + rename { "${it}_${project.base.archivesName.get()}" } + } +} + +// configure the maven publication +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. + } +} + +def ENV = System.getenv() + +// from FAPI https://github.com/FabricMC/fabric/blob/1.16/build.gradle +curseforge { + if (ENV.CURSEFORGE_API_KEY) { + apiKey = ENV.CURSEFORGE_API_KEY + } + + project { + id = "446499" + changelog = ENV.CHANGELOG ?: "A changelog can be found at https://github.com/samolego/Taterzens/releases/tag/${version}" + releaseType = "release" + addGameVersion "${project.minecraft_version}" + addGameVersion "Fabric" + addGameVersion "Quilt" + + mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}-fabric.jar")) { + displayName = "[${project.minecraft_version}] Taterzens ${version}" + } + + afterEvaluate { + uploadTask.dependsOn("remapJar") + } + } + + options { + forgeGradleIntegration = false + } +} + +modrinth { + token = ENV.MODRINTH_TOKEN + projectId = "vE972Kux" + versionNumber = project.minecraft_version + "+" + version + "-fabric" + versionType = "release" + changelog = ENV.CHANGELOG ?: "A changelog can be found at https://github.com/samolego/Taterzens/releases/tag/${version}" + versionName = "[${project.minecraft_version}] Taterzens ${version} [Fabric]" + + uploadFile = file("${project.buildDir}/libs/${archivesBaseName}-${version}-fabric.jar") + + gameVersions = ["${project.minecraft_version}"] + loaders = ['fabric', 'quilt'] + + dependencies { // A special DSL for creating dependencies + required.project "fabric-api" // Creates a new required dependency on Fabric API + } } diff --git a/common/build.gradle b/common/build.gradle deleted file mode 100644 index e69de29bb..000000000 diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_PacketFaker.java b/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_PacketFaker.java deleted file mode 100644 index 0c0f170b9..000000000 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_PacketFaker.java +++ /dev/null @@ -1,147 +0,0 @@ -package org.samo_lego.taterzens.mixin.network; - -import com.mojang.authlib.GameProfile; -import net.minecraft.network.Connection; -import net.minecraft.network.PacketSendListener; -import net.minecraft.network.protocol.BundlePacket; -import net.minecraft.network.protocol.Packet; -import net.minecraft.network.protocol.game.*; -import net.minecraft.network.syncher.SynchedEntityData; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.server.network.CommonListenerCookie; -import net.minecraft.server.network.ServerCommonPacketListenerImpl; -import net.minecraft.server.network.ServerGamePacketListenerImpl; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.GameType; -import net.minecraft.world.level.Level; -import org.samo_lego.taterzens.interfaces.ITaterzenEditor; -import org.samo_lego.taterzens.mixin.accessors.AClientboundPlayerInfoUpdatePacket; -import org.samo_lego.taterzens.mixin.accessors.AClientboundSetEntityDataPacket; -import org.samo_lego.taterzens.npc.TaterzenNPC; -import org.samo_lego.taterzens.util.NpcPlayerUpdate; -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 java.util.*; - -import static org.samo_lego.taterzens.Taterzens.config; - -/** - * Used to "fake" the TaterzenNPC entity type. - */ -@Mixin(value = ServerGamePacketListenerImpl.class, priority = 900) -public abstract class ServerGamePacketListenerImplMixin_PacketFaker extends ServerCommonPacketListenerImpl { - - @Unique - private final Map tablistQueue = new LinkedHashMap<>(); - @Shadow - public ServerPlayer player; - @Unique - private boolean skipCheck = false; - @Unique - private int queueTick; - - @Unique - private final ServerGamePacketListenerImpl self = (ServerGamePacketListenerImpl) (Object) this; - - public ServerGamePacketListenerImplMixin_PacketFaker(MinecraftServer minecraftServer, Connection connection, CommonListenerCookie commonListenerCookie) { - super(minecraftServer, connection, commonListenerCookie); - } - - - /** - * Changes entity type if entity is an instance of {@link TaterzenNPC}. - */ - @Inject(method = "send", - at = @At(value = "INVOKE", target = "Lnet/minecraft/network/Connection;send(Lnet/minecraft/network/protocol/Packet;Lnet/minecraft/network/PacketSendListener;)V"), - cancellable = true) - private void taterzen_changeEntityType(Packet packet, PacketSendListener listener, CallbackInfo ci) { - Level world = player.level(); - if (packet instanceof BundlePacket bPacket && !this.skipCheck) { - for (Packet subPacket : bPacket.subPackets()) { - if (subPacket instanceof ClientboundAddEntityPacket) { - Entity entity = world.getEntity(((ClientboundAddEntityPacket) subPacket).getId()); - - if (!(entity instanceof TaterzenNPC npc)) return; - - GameProfile profile = npc.getGameProfile(); - //ClientboundPlayerInfoUpdatePacket playerAddPacket = new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, npc.getFakePlayer()); - ClientboundPlayerInfoUpdatePacket playerAddPacket = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(Collections.singleton(npc.getFakePlayer())); - //noinspection ConstantConditions - var entry = new ClientboundPlayerInfoUpdatePacket.Entry(profile.getId(), profile, false, 0, GameType.SURVIVAL, npc.getDisplayName(), null); - ((AClientboundPlayerInfoUpdatePacket) playerAddPacket).setEntries(Collections.singletonList(entry)); - self.send(playerAddPacket, listener); - - // Before we send this packet, we have - // added player to tablist, otherwise client doesn't - // show it ... :mojank: - this.skipCheck = true; - self.send(packet, listener); - this.skipCheck = false; - - // And now we can remove it from tablist - // we must delay the tablist packet so as to allow - // the client to fetch skin. - // If player is immediately removed from the tablist, - // client doesn't care about the skin. - if (config.taterzenTablistTimeout != -1) { - var uuid = npc.getGameProfile().getId(); - tablistQueue.remove(uuid); - tablistQueue.put(uuid, new NpcPlayerUpdate(npc.getGameProfile(), npc.getTabListName(), queueTick + config.taterzenTablistTimeout)); - } - - self.send(new ClientboundRotateHeadPacket(entity, (byte) ((int) (entity.getYHeadRot() * 256.0F / 360.0F))), listener); - - ci.cancel(); - } else if (subPacket instanceof ClientboundSetEntityDataPacket) { - Entity entity = world.getEntity(((AClientboundSetEntityDataPacket) subPacket).getEntityId()); - - if (!(entity instanceof TaterzenNPC taterzen)) return; - Player fakePlayer = taterzen.getFakePlayer(); - List> trackedValues = fakePlayer.getEntityData().getNonDefaultValues(); - - if (Optional.of(taterzen).equals(((ITaterzenEditor) this.player).getSelectedNpc()) && trackedValues != null && config.glowSelectedNpc) { - trackedValues.removeIf(value -> value.id() == 0); - byte flags = fakePlayer.getEntityData().get(Entity.DATA_SHARED_FLAGS_ID); - // Modify Taterzen to have fake glowing effect for the player - flags = (byte) (flags | 1 << Entity.FLAG_GLOWING); - - SynchedEntityData.DataValue glowingTag = SynchedEntityData.DataValue.create(Entity.DATA_SHARED_FLAGS_ID, flags); - trackedValues.add(glowingTag); - } - - ((AClientboundSetEntityDataPacket) subPacket).setPackedItems(trackedValues); - } - } - } - } - - @Inject(method = "handleMovePlayer", at = @At("RETURN")) - private void removeTaterzenFromTablist(CallbackInfo ci) { - if (tablistQueue.isEmpty()) return; - - queueTick++; - - List toRemove = new ArrayList<>(); - for (var iterator = tablistQueue.values().iterator(); iterator.hasNext(); ) { - var current = iterator.next(); - if (current.removeAt() > queueTick) break; - - iterator.remove(); - toRemove.add(current.profile().getId()); - } - if (toRemove.isEmpty()) return; - - ClientboundPlayerInfoRemovePacket taterzensRemovePacket = new ClientboundPlayerInfoRemovePacket(toRemove); - - this.skipCheck = true; - self.send(taterzensRemovePacket); - this.skipCheck = false; - } -} diff --git a/common/src/main/java/org/samo_lego/taterzens/util/NpcPlayerUpdate.java b/common/src/main/java/org/samo_lego/taterzens/util/NpcPlayerUpdate.java deleted file mode 100644 index fa79c5918..000000000 --- a/common/src/main/java/org/samo_lego/taterzens/util/NpcPlayerUpdate.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.samo_lego.taterzens.util; - -import com.mojang.authlib.GameProfile; -import net.minecraft.network.chat.Component; - -/** - * An NPC which is queued to be removed from the tab list at a future point. - * - * @param profile The game profile we're removing from the tab list. - * @param displayName The NPC's display name. - * @param removeAt The tick at which this NPC should be removed. - * @see org.samo_lego.taterzens.mixin.network.ServerGamePacketListenerImplMixin_PacketFaker - */ -public record NpcPlayerUpdate(GameProfile profile, Component displayName, long removeAt) { -} diff --git a/fabric/build.gradle b/fabric/build.gradle deleted file mode 100644 index 484ea33b8..000000000 --- a/fabric/build.gradle +++ /dev/null @@ -1,82 +0,0 @@ -def ENV = System.getenv() - -dependencies { - // Carpet - modCompileOnly("com.github.gnembon:fabric-carpet:${project.carpet_core_version}") - - // Patbox's library for registry sync manipulation - modImplementation include("eu.pb4:polymer-reg-sync-manipulator:${project.polymer_registry_sync_version}") - - // Permission API - modImplementation(include('me.lucko:fabric-permissions-api:0.1-SNAPSHOT')) - - // Server translations - modImplementation include("xyz.nucleoid:server-translations-api:${project.translations_api}") - - // SGUI - modImplementation(include("eu.pb4:sgui:${project.sgui_version}")) - - // C2B - include("com.github.samolego.Config2Brigadier:config2brigadier-fabric:${rootProject.c2b_version}") - - // Disguiselib - modImplementation("xyz.nucleoid:disguiselib-fabric:${project.disguiselib_version}") -} - -processResources { - inputs.property "version", rootProject.version - - filesMatching("fabric.mod.json") { - expand "version": rootProject.version - } - - filesMatching("taterzens.common.mixins.json") { - expand "refmap": "taterzens-${project.name}-${rootProject.minecraft_version}-refmap.json" - } -} - -// from FAPI https://github.com/FabricMC/fabric/blob/1.16/build.gradle -curseforge { - if (ENV.CURSEFORGE_API_KEY) { - apiKey = ENV.CURSEFORGE_API_KEY - } - - project { - id = "446499" - changelog = ENV.CHANGELOG ?: "A changelog can be found at https://github.com/samolego/Taterzens/releases/tag/${version}" - releaseType = "release" - addGameVersion "${project.minecraft_version}" - addGameVersion "Fabric" - addGameVersion "Quilt" - - mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}-fabric.jar")) { - displayName = "[${project.minecraft_version}] Taterzens ${version}" - } - - afterEvaluate { - uploadTask.dependsOn("remapJar") - } - } - - options { - forgeGradleIntegration = false - } -} - -modrinth { - token = ENV.MODRINTH_TOKEN - projectId = "vE972Kux" - versionNumber = project.minecraft_version + "+" + version + "-fabric" - versionType = "release" - changelog = ENV.CHANGELOG ?: "A changelog can be found at https://github.com/samolego/Taterzens/releases/tag/${version}" - versionName = "[${project.minecraft_version}] Taterzens ${version} [Fabric]" - - uploadFile = file("${project.buildDir}/libs/${archivesBaseName}-${version}-fabric.jar") - - gameVersions = ["${project.minecraft_version}"] - loaders = ['fabric', 'quilt'] - - dependencies { // A special DSL for creating dependencies - required.project "fabric-api" // Creates a new required dependency on Fabric API - } -} diff --git a/fabric/gradle.properties b/fabric/gradle.properties deleted file mode 100644 index 3cf077b32..000000000 --- a/fabric/gradle.properties +++ /dev/null @@ -1,5 +0,0 @@ -# Dependecies -polymer_registry_sync_version=0.6.0+1.20.2 -sgui_version=1.3.0+1.20.2 -carpet_core_version=1.4.119 -translations_api=2.1.0+1.20.2-rc2 diff --git a/fabric/src/main/java/org/samo_lego/taterzens/fabric/client_fix/ClientInit.java b/fabric/src/main/java/org/samo_lego/taterzens/fabric/client_fix/ClientInit.java deleted file mode 100644 index 925945bbf..000000000 --- a/fabric/src/main/java/org/samo_lego/taterzens/fabric/client_fix/ClientInit.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.samo_lego.taterzens.fabric.client_fix; - -import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; -import net.minecraft.client.model.PlayerModel; -import net.minecraft.client.model.geom.ModelLayers; -import net.minecraft.client.renderer.entity.MobRenderer; -import net.minecraft.client.resources.DefaultPlayerSkin; -import net.minecraft.resources.ResourceLocation; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.npc.TaterzenNPC; - -@Environment(EnvType.CLIENT) -public class ClientInit implements ClientModInitializer { - @Override - public void onInitializeClient() { - // We just do this to avoid client crashes - EntityRendererRegistry.register(Taterzens.TATERZEN_TYPE.get(), context -> new MobRenderer<>(context, new PlayerModel<>(context.bakeLayer(ModelLayers.PLAYER), false), 1.0F) { - @Override - public ResourceLocation getTextureLocation(TaterzenNPC entity) { - return DefaultPlayerSkin.getDefaultSkin(entity.getUUID()); - } - }); - } -} diff --git a/forge/build.gradle b/forge/build.gradle deleted file mode 100644 index 1103572db..000000000 --- a/forge/build.gradle +++ /dev/null @@ -1,204 +0,0 @@ -plugins { - id 'net.minecraftforge.gradle' -} - -minecraft { - // The mappings can be changed at any time and must be in the following format. - // Channel: Version: - // official MCVersion Official field/method names from Mojang mapping files - // parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official - - mappings channel: "official", version: rootProject.minecraft_version - - // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default. - - // Default run configurations. - // These can be tweaked, removed, or duplicated as needed. - runs { - client { - workingDirectory project.file('run') - - // Recommended logging data for a userdev environment - // The markers can be added/remove as needed separated by commas. - // "SCAN": For mods scan. - // "REGISTRIES": For firing of registry events. - // "REGISTRYDUMP": For getting the contents of all registries. - property 'forge.logging.markers', 'REGISTRIES' - - // Recommended logging level for the console - // You can set various levels here. - // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels - property 'forge.logging.console.level', 'debug' - - // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. - property 'forge.enabledGameTestNamespaces', rootProject.archives_base_name - - // These arguments allow for optional authentication with Mojang servers. - // If you want to authenticate, put these properties in GRADLE_HOME/gradle.properties. - // By default, this is C:\Users\\.gradle\gradle.properties on Windows or ~/.gradle/gradle.properties on Linux/MacOS. - if (project.hasProperty('mc_uuid')) { - // Your UUID, trimmed / without the dashes - args '--uuid', project.getProperty('mc_uuid') - } - if (project.hasProperty('mc_username')) { - // Your Minecraft in-game username, not email - args '--username', project.getProperty('mc_username') - } - if (project.hasProperty('mc_accessToken')) { - // Your current access token. When it expires, you need to retrieve a new one and regenerate your run configurations. - // You may be able to find it in your .minecraft folder in launcher_accounts.json or launcher_profiles.json. - args '--accessToken', project.getProperty('mc_accessToken') - } - - mods { - "${rootProject.archives_base_name}" { - source sourceSets.main - } - } - } - - server { - workingDirectory project.file('run') - - property 'forge.logging.markers', 'REGISTRIES' - - property 'forge.logging.console.level', 'debug' - - property 'forge.enabledGameTestNamespaces', rootProject.archives_base_name - - mods { - "${rootProject.archives_base_name}" { - source sourceSets.main - } - } - } - - // This run config launches GameTestServer and runs all registered gametests, then exits. - // By default, the server will crash when no gametests are provided. - // The gametest system is also enabled by default for other run configs under the /test command. - gameTestServer { - workingDirectory project.file('run') - - property 'forge.logging.markers', 'REGISTRIES' - - property 'forge.logging.console.level', 'debug' - - property 'forge.enabledGameTestNamespaces', rootProject.archives_base_name - - mods { - "${rootProject.archives_base_name}" { - source sourceSets.main - } - } - } - - data { - workingDirectory project.file('run') - - property 'forge.logging.markers', 'REGISTRIES' - - property 'forge.logging.console.level', 'debug' - - // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. - args '--mod', rootProject.archives_base_name, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') - - mods { - "${rootProject.archives_base_name}" { - source sourceSets.main - } - } - } - } -} - -// Include resources generated by data generators. -sourceSets.main.resources { srcDir 'src/generated/resources' } - -dependencies { - // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed - // that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied. - // The userdev artifact is a special name and will get all sorts of transformations applied to it. - minecraft "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}" - - // Real mod deobf dependency examples - these get remapped to your current mappings - // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency - // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency - // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency - - // Examples using mod jars from ./libs - // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}") - - // For more info... - // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html - // http://www.gradle.org/docs/current/userguide/dependency_management.html - implementation "com.github.samolego.Config2Brigadier:config2brigadier-forge:${rootProject.c2b_version}" -} - -// This block of code expands all the gradle properties in the specified resource targets. -// It copies them into the targets and expands all the defined properties. -def resourceTargets = ['META-INF/mods.toml', 'pack.mcmeta'] -def intoTargets = ["$rootDir/out/production/resources/", "$rootDir/out/production/${project.name}.main/", "$rootDir/bin/main/"] - -def ENV = System.getenv() - -processResources { - inputs.property "version", project.version - inputs.property "c2b_version", rootProject.c2b_version - - filesMatching("META-INF/mods.toml") { - expand("version": project.version, - "c2b_version": rootProject.c2b_version - ) - } - - intoTargets.each { target -> - if (file(target).exists()) { - copy { - from(sourceSets.main.resources) { - include resourceTargets - expand replaceProperties - } - into target - } - } - } -} - - -curseforge { - if (ENV.CURSEFORGE_API_KEY) { - apiKey = ENV.CURSEFORGE_API_KEY - } - - project { - id = "473071" - changelog = ENV.CHANGELOG ?: "A changelog can be found at https://github.com/samolego/Taterzens/releases/tag/${version}" - releaseType = "release" - addGameVersion "${project.minecraft_version}" - addGameVersion "Forge" - - mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}-forge.jar")) { - displayName = "[${project.minecraft_version}] Taterzens ${version}" - } - } - - options { - forgeGradleIntegration = false - } -} - - -modrinth { - token = ENV.MODRINTH_TOKEN - projectId = "vE972Kux" - versionNumber = project.minecraft_version + "+" + version + "-forge" - versionType = "release" - changelog = ENV.CHANGELOG ?: "A changelog can be found at https://github.com/samolego/Taterzens/releases/tag/${version}" - versionName = "[${project.minecraft_version}] Taterzens ${version} [Forge]" - - uploadFile = file("${project.buildDir}/libs/${archivesBaseName}-${version}-forge.jar") - - gameVersions = ["${project.minecraft_version}"] - loaders = ['forge'] - -} diff --git a/forge/src/main/java/org/samo_lego/taterzens/forge/TaterzensForge.java b/forge/src/main/java/org/samo_lego/taterzens/forge/TaterzensForge.java deleted file mode 100644 index b36bbac6f..000000000 --- a/forge/src/main/java/org/samo_lego/taterzens/forge/TaterzensForge.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.samo_lego.taterzens.forge; - -import net.minecraft.world.entity.EntityType; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.forge.event.EventHandler; -import org.samo_lego.taterzens.forge.platform.ForgePlatform; - -import static org.samo_lego.taterzens.Taterzens.MOD_ID; - -@Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) -@Mod(MOD_ID) -public class TaterzensForge { - public static final DeferredRegister> ENTITY_TYPE_REGISTER = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, MOD_ID); - - public TaterzensForge() { - var evtBus = FMLJavaModLoadingContext.get().getModEventBus(); - MinecraftForge.EVENT_BUS.register(new EventHandler()); - ENTITY_TYPE_REGISTER.register(evtBus); - - new Taterzens(new ForgePlatform()); - } -} \ No newline at end of file diff --git a/forge/src/main/java/org/samo_lego/taterzens/forge/event/EventHandler.java b/forge/src/main/java/org/samo_lego/taterzens/forge/event/EventHandler.java deleted file mode 100644 index c2cb55b6c..000000000 --- a/forge/src/main/java/org/samo_lego/taterzens/forge/event/EventHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.samo_lego.taterzens.forge.event; - -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraftforge.event.RegisterCommandsEvent; -import net.minecraftforge.event.entity.EntityAttributeCreationEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.event.BlockEvent; -import org.samo_lego.taterzens.npc.TaterzenNPC; - -import static org.samo_lego.taterzens.Taterzens.MOD_ID; -import static org.samo_lego.taterzens.Taterzens.TATERZEN_TYPE; - -@Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) -public record EventHandler() { - - @SubscribeEvent - public static void onBlockInteract(PlayerInteractEvent.RightClickBlock event) { - Player player = event.getEntity(); - if (BlockEvent.onBlockInteract(player, player.getCommandSenderWorld(), event.getPos()) == InteractionResult.FAIL) { - event.setCanceled(true); - } - } - - @SubscribeEvent - public void registerCommands(RegisterCommandsEvent event) { - Taterzens.registerCommands(event.getDispatcher(), event.getBuildContext()); - } - - @SubscribeEvent - public static void entityAttributes(EntityAttributeCreationEvent event) { - event.put(TATERZEN_TYPE.get(), TaterzenNPC.createTaterzenAttributes().build()); - } -} diff --git a/forge/src/main/java/org/samo_lego/taterzens/forge/platform/ForgePlatform.java b/forge/src/main/java/org/samo_lego/taterzens/forge/platform/ForgePlatform.java deleted file mode 100644 index acb85e27c..000000000 --- a/forge/src/main/java/org/samo_lego/taterzens/forge/platform/ForgePlatform.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.samo_lego.taterzens.forge.platform; - -import net.minecraft.commands.CommandSourceStack; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.MobCategory; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.loading.FMLPaths; -import net.minecraftforge.registries.RegistryManager; -import org.samo_lego.taterzens.npc.TaterzenNPC; -import org.samo_lego.taterzens.platform.Platform; -import org.samo_lego.taterzens.util.TextUtil; - -import java.nio.file.Path; - -import static org.samo_lego.taterzens.Taterzens.NPC_ID; -import static org.samo_lego.taterzens.Taterzens.TATERZEN_TYPE; -import static org.samo_lego.taterzens.forge.TaterzensForge.ENTITY_TYPE_REGISTER; - -public class ForgePlatform extends Platform { - - private static final ResourceLocation ITEM_ID = new ResourceLocation("item"); - - @Override - public Path getConfigDirPath() { - return FMLPaths.CONFIGDIR.get(); - - } - - @Override - public boolean isModLoaded(String modId) { - return ModList.get().isLoaded(modId); - } - - @Override - public int getItemRegistrySize() { - return RegistryManager.ACTIVE.getRegistry(ITEM_ID).getValues().size(); - } - - @Override - public boolean checkPermission(CommandSourceStack source, String permissionNode, int fallbackLevel) { - return source.hasPermission(fallbackLevel); - } - - @Override - public void registerTaterzenType() { - TATERZEN_TYPE = ENTITY_TYPE_REGISTER.register(NPC_ID.getPath(), () -> EntityType.Builder - .of(TaterzenNPC::new, MobCategory.MISC) - .sized(0.6F, 1.8F) - .build(NPC_ID.getPath())); - } - - @Override - public void clearDisguise(TaterzenNPC taterzen) { - - } - - @Override - public void disguiseAs(TaterzenNPC taterzen, Entity entity) { - - } - - @Override - public void openEditorGui(ServerPlayer player) { - player.sendSystemMessage(TextUtil.translate("taterzens.gui.forge")); - } -} diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml deleted file mode 100644 index 20bc8b30e..000000000 --- a/forge/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,57 +0,0 @@ -modLoader = "javafml" -loaderVersion = "[37,)" -issueTrackerURL = "https://github.com/samolego/Taterzens/issues" -license = "MIT" - -[[mods]] -modId = "taterzens" -version = "${version}" -displayName = "Taterzens" -displayURL="https://samolego.github.io/Taterzens" -authors = "samo_lego" -description = ''' -A citizens like mod. -''' -logoFile = "taterzens_icon.png" - -[[dependencies.taterzens]] -modId = "forge" -mandatory = true -versionRange = "[38,)" -ordering = "NONE" -side = "SERVER" - -[[dependencies.taterzens]] -modId = "minecraft" -mandatory = true -versionRange = "[1.18,)" -ordering = "NONE" -side = "SERVER" - -# C2B Lib -modLoader = "javafml" -loaderVersion = "[37,)" -license = "LGPL-v3.0" - -[[mods]] -modId = "config2brigadier" -version = "${c2b_version}" -displayName = "Config to Brigadier" -authors = "samo_lego" -description = ''' -A library to automagically generate in-game command for config editing. -''' - -[[dependencies.config2brigadier]] -modId = "forge" -mandatory = true -versionRange = "[37,)" -ordering = "NONE" -side = "BOTH" - -[[dependencies.config2brigadier]] -modId = "minecraft" -mandatory = true -versionRange = "[1.17.1,)" -ordering = "NONE" -side = "BOTH" diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta deleted file mode 100644 index dd1bf31d8..000000000 --- a/forge/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack": { - "description": "Taterzens", - "pack_format": 6 - } -} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 919720856..2466fe4ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,21 +1,24 @@ # Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx2G -# Fabric Properties -minecraft_version=1.20.2 -yarn_mappings=1.20.2+build.4 -loader_version=0.14.22 +org.gradle.jvmargs=-Xmx1G +org.gradle.parallel=true -#Fabric api -fabric_version=0.89.3+1.20.2 +# Fabric Properties +# check these on https://fabricmc.net/develop +minecraft_version=1.21 +yarn_mappings=1.21+build.7 +loader_version=0.15.11 +fabric_version=0.100.4+1.21 -#Forge -forge_version=47.1.43 -enable_forge=false # Mod Properties -mod_version=1.11.7 +# Updated mod_version to ensure FabricTailor compat retained +mod_version=1.15.5 maven_group=org.samo_lego archives_base_name=taterzens + # Dependencies -disguiselib_version=1.3.3 +disguiselib_version=1.3.5 c2b_version=10b43346ec - +carpet_core_version=1.4.128 +polymer_version=0.9.7+1.21 +sgui_version=1.6.0+1.21 +translations_api=2.2.0+1.20.3-rc1 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f2..d64cd4917 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 29273b051..1af9e0930 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists - diff --git a/gradlew b/gradlew index c53aefaa5..1aa94a426 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright 2015-2021 the original authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: # * functions; -# * expansions $var, ${var}, ${var:-default}, ${var+SET}, -# ${var#prefix}, ${var%suffix}, and $( cmd ); -# * compound commands having a testable exit status, especially case; -# * various built-in commands including command, set, and ulimit. +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». # # Important for patching: # @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +131,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ @@ -205,6 +214,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd32c..93e3f59f1 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/settings.gradle b/settings.gradle index 0f62d800f..75c4d726a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,16 +1,10 @@ pluginManagement { - repositories { - maven { url "https://maven.fabricmc.net/" } - maven { url = "https://maven.quiltmc.org/repository/release" } - maven { url "https://maven.minecraftforge.net/" } - gradlePluginPortal() - } -} - -include("common") -include("fabric") - -// Include only if "enable_forge" in gradle.properties is true -if (enable_forge.toBoolean()) { - include("forge") -} + repositories { + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + mavenCentral() + gradlePluginPortal() + } +} \ No newline at end of file diff --git a/src/client/java/org/samo_lego/taterzens/client/TaterzensClient.java b/src/client/java/org/samo_lego/taterzens/client/TaterzensClient.java new file mode 100644 index 000000000..13f035b35 --- /dev/null +++ b/src/client/java/org/samo_lego/taterzens/client/TaterzensClient.java @@ -0,0 +1,26 @@ +package org.samo_lego.taterzens.client; + +import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; +import net.minecraft.client.model.PlayerModel; +import net.minecraft.client.model.geom.ModelLayers; +import net.minecraft.client.renderer.entity.MobRenderer; +import net.minecraft.client.resources.DefaultPlayerSkin; +import net.minecraft.resources.ResourceLocation; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; + +public class TaterzensClient implements ClientModInitializer { + @Override + public void onInitializeClient() { + // We just do this to avoid client crashes + /* + EntityRendererRegistry.register(Taterzens.TATERZEN_TYPE.get(), context -> new MobRenderer<>(context, new PlayerModel<>(context.bakeLayer(ModelLayers.PLAYER), false), 1.0F) { + @Override + public ResourceLocation getTextureLocation(TaterzenNPC entity) { + return DefaultPlayerSkin.getDefaultTexture(); + } + }); + */ + } +} diff --git a/src/client/resources/taterzens.client.mixins.json b/src/client/resources/taterzens.client.mixins.json new file mode 100644 index 000000000..931c8f6e5 --- /dev/null +++ b/src/client/resources/taterzens.client.mixins.json @@ -0,0 +1,11 @@ +{ + "required": true, + "package": "org.samo_lego.mixin.client", + "compatibilityLevel": "JAVA_17", + "client": [ + "ExampleClientMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/common/src/main/java/org/samo_lego/taterzens/Taterzens.java b/src/main/java/org/samo_lego/taterzens/common/Taterzens.java similarity index 75% rename from common/src/main/java/org/samo_lego/taterzens/Taterzens.java rename to src/main/java/org/samo_lego/taterzens/common/Taterzens.java index 8406ca01a..d01c169e0 100644 --- a/common/src/main/java/org/samo_lego/taterzens/Taterzens.java +++ b/src/main/java/org/samo_lego/taterzens/common/Taterzens.java @@ -1,25 +1,26 @@ -package org.samo_lego.taterzens; +package org.samo_lego.taterzens.common; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.mojang.brigadier.CommandDispatcher; +import eu.pb4.polymer.core.api.entity.PolymerEntityUtils; import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandSourceStack; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityType; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.core.Logger; -import org.samo_lego.taterzens.api.professions.TaterzenProfession; -import org.samo_lego.taterzens.commands.NpcCommand; -import org.samo_lego.taterzens.commands.NpcGUICommand; -import org.samo_lego.taterzens.commands.ProfessionCommand; -import org.samo_lego.taterzens.commands.TaterzensCommand; -import org.samo_lego.taterzens.compatibility.ModDiscovery; -import org.samo_lego.taterzens.npc.TaterzenNPC; -import org.samo_lego.taterzens.platform.Platform; -import org.samo_lego.taterzens.storage.TaterConfig; -import org.samo_lego.taterzens.util.LanguageUtil; +import org.samo_lego.taterzens.common.api.professions.TaterzenProfession; +import org.samo_lego.taterzens.common.commands.NpcCommand; +import org.samo_lego.taterzens.common.commands.NpcGUICommand; +import org.samo_lego.taterzens.common.commands.ProfessionCommand; +import org.samo_lego.taterzens.common.compatibility.ModDiscovery; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.platform.Platform; +import org.samo_lego.taterzens.common.storage.TaterConfig; +import org.samo_lego.taterzens.common.util.LanguageUtil; +import org.samo_lego.taterzens.common.commands.TaterzensCommand; import java.io.File; import java.util.*; @@ -40,14 +41,14 @@ public class Taterzens { /** * Language file. */ - public static JsonObject lang; + public static JsonObject lang = new JsonObject(); /** * List of **loaded** {@link TaterzenNPC TaterzenNPCs}. */ public static final Map TATERZEN_NPCS = Collections.synchronizedMap(new LinkedHashMap<>()); - public static final HashMap> PROFESSION_TYPES = new HashMap<>(); + public static final Map> PROFESSION_TYPES = new HashMap<>(); public static final Gson GSON; /** @@ -55,7 +56,8 @@ public class Taterzens { * when packets are sent. */ public static Supplier> TATERZEN_TYPE; - public static final ResourceLocation NPC_ID = new ResourceLocation(MOD_ID, "npc"); + // Updated to 1.21 ResourceLocation changes + public static final ResourceLocation NPC_ID = ResourceLocation.fromNamespaceAndPath(MOD_ID, "npc"); private final File configFile; @@ -85,6 +87,7 @@ public Taterzens(Platform platform) { LanguageUtil.setupLanguage(); + PolymerEntityUtils.registerType(TATERZEN_TYPE.get()); } /** diff --git a/common/src/main/java/org/samo_lego/taterzens/api/TaterzensAPI.java b/src/main/java/org/samo_lego/taterzens/common/api/TaterzensAPI.java similarity index 93% rename from common/src/main/java/org/samo_lego/taterzens/api/TaterzensAPI.java rename to src/main/java/org/samo_lego/taterzens/common/api/TaterzensAPI.java index efb201c9b..504369a15 100644 --- a/common/src/main/java/org/samo_lego/taterzens/api/TaterzensAPI.java +++ b/src/main/java/org/samo_lego/taterzens/common/api/TaterzensAPI.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.api; +package org.samo_lego.taterzens.common.api; import com.google.gson.JsonElement; import com.google.gson.JsonParser; @@ -12,13 +12,12 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.SkullBlockEntity; import net.minecraft.world.phys.Vec3; import net.minecraft.world.scores.Team; import org.jetbrains.annotations.Nullable; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.api.professions.TaterzenProfession; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.api.professions.TaterzenProfession; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.io.*; import java.nio.charset.StandardCharsets; @@ -26,7 +25,8 @@ import java.util.List; import java.util.function.Function; -import static org.samo_lego.taterzens.Taterzens.*; +import static com.mojang.text2speech.Narrator.LOGGER; +import static org.samo_lego.taterzens.common.Taterzens.*; /** * Class containing static methods to use with Taterzens. @@ -137,7 +137,7 @@ public static TaterzenNPC createTaterzen(ServerLevel world, String displayName, taterzen.moveTo(pos.x(), pos.y(), pos.z(), rotations[1], rotations[2]); taterzen.setYHeadRot(rotations[0]); taterzen.setCustomName(Component.literal(displayName)); - SkullBlockEntity.updateGameprofile(taterzen.getGameProfile(), taterzen::applySkin); + //todo SkullBlockEntity.updateGameprofile(taterzen.getGameProfile(), taterzen::applySkin); return taterzen; } @@ -171,7 +171,7 @@ public static void registerProfession(ResourceLocation professionId, Function getPresets() { List files = new ArrayList<>(); File[] presets = Taterzens.getInstance().getPresetDirectory().listFiles(); - if(presets != null) { + if (presets != null) { final String ending = ".json"; for(File preset : presets) { if(preset.isFile() && preset.getName().endsWith(ending)) diff --git a/common/src/main/java/org/samo_lego/taterzens/api/professions/AbstractProfession.java b/src/main/java/org/samo_lego/taterzens/common/api/professions/AbstractProfession.java similarity index 63% rename from common/src/main/java/org/samo_lego/taterzens/api/professions/AbstractProfession.java rename to src/main/java/org/samo_lego/taterzens/common/api/professions/AbstractProfession.java index 5d09c7a65..a104a8efb 100644 --- a/common/src/main/java/org/samo_lego/taterzens/api/professions/AbstractProfession.java +++ b/src/main/java/org/samo_lego/taterzens/common/api/professions/AbstractProfession.java @@ -1,6 +1,6 @@ -package org.samo_lego.taterzens.api.professions; +package org.samo_lego.taterzens.common.api.professions; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; public abstract class AbstractProfession implements TaterzenProfession { diff --git a/common/src/main/java/org/samo_lego/taterzens/api/professions/TaterzenProfession.java b/src/main/java/org/samo_lego/taterzens/common/api/professions/TaterzenProfession.java similarity index 97% rename from common/src/main/java/org/samo_lego/taterzens/api/professions/TaterzenProfession.java rename to src/main/java/org/samo_lego/taterzens/common/api/professions/TaterzenProfession.java index 7514077da..9fc87a9e5 100644 --- a/common/src/main/java/org/samo_lego/taterzens/api/professions/TaterzenProfession.java +++ b/src/main/java/org/samo_lego/taterzens/common/api/professions/TaterzenProfession.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.api.professions; +package org.samo_lego.taterzens.common.api.professions; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerPlayer; @@ -9,8 +9,8 @@ import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.phys.Vec3; -import org.samo_lego.taterzens.npc.NPCData; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.npc.NPCData; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.util.List; diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/ActionCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/ActionCommand.java similarity index 89% rename from common/src/main/java/org/samo_lego/taterzens/commands/ActionCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/ActionCommand.java index 8dfd1824a..ecdaffecc 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/ActionCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/ActionCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands; +package org.samo_lego.taterzens.common.commands; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -6,14 +6,14 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.coordinates.BlockPosArgument; import net.minecraft.core.BlockPos; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.npc.NPCData; +import org.samo_lego.taterzens.common.npc.NPCData; +import org.samo_lego.taterzens.common.Taterzens; import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.errorText; -import static org.samo_lego.taterzens.util.TextUtil.successText; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.errorText; +import static org.samo_lego.taterzens.common.util.TextUtil.successText; public class ActionCommand { public static void registerNode(LiteralCommandNode npcNode) { diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/LockCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/LockCommand.java similarity index 89% rename from common/src/main/java/org/samo_lego/taterzens/commands/LockCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/LockCommand.java index 677f34f8f..b748cd7a3 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/LockCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/LockCommand.java @@ -1,15 +1,15 @@ -package org.samo_lego.taterzens.commands; +package org.samo_lego.taterzens.common.commands; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.tree.LiteralCommandNode; import net.minecraft.commands.CommandSourceStack; import net.minecraft.world.entity.Entity; -import org.samo_lego.taterzens.Taterzens; +import org.samo_lego.taterzens.common.Taterzens; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.successText; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.successText; public class LockCommand { public static void registerNode(LiteralCommandNode npcNode) { diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/NpcCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/NpcCommand.java similarity index 96% rename from common/src/main/java/org/samo_lego/taterzens/commands/NpcCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/NpcCommand.java index 2828286ad..c2deee9ba 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/NpcCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/NpcCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands; +package org.samo_lego.taterzens.common.commands; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.IntegerArgumentType; @@ -21,12 +21,12 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.api.TaterzensAPI; -import org.samo_lego.taterzens.commands.edit.EditCommand; -import org.samo_lego.taterzens.interfaces.ITaterzenEditor; -import org.samo_lego.taterzens.mixin.accessors.ACommandSourceStack; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.api.TaterzensAPI; +import org.samo_lego.taterzens.common.commands.edit.EditCommand; +import org.samo_lego.taterzens.common.interfaces.ITaterzenEditor; +import org.samo_lego.taterzens.common.mixin.accessors.ACommandSourceStack; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.util.*; import java.util.function.Consumer; @@ -35,9 +35,9 @@ import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; import static net.minecraft.commands.arguments.MessageArgument.message; -import static org.samo_lego.taterzens.Taterzens.TATERZEN_NPCS; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.*; +import static org.samo_lego.taterzens.common.Taterzens.TATERZEN_NPCS; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.*; public class NpcCommand { public static LiteralCommandNode npcNode; @@ -97,7 +97,10 @@ public static void register(CommandDispatcher dispatcher, Co EditCommand.registerNode(dispatcher, npcNode, commandBuildContext); PresetCommand.registerNode(npcNode); - TeleportCommand.registerNode(npcNode); + + // TODO: Fix the Teleport implementation to meet the 1.21 changes + //TeleportCommand.registerNode(npcNode); + ActionCommand.registerNode(npcNode); LockCommand.registerNode(npcNode); } diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/NpcGUICommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/NpcGUICommand.java similarity index 81% rename from common/src/main/java/org/samo_lego/taterzens/commands/NpcGUICommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/NpcGUICommand.java index 96fd6d522..2bd25fe4d 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/NpcGUICommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/NpcGUICommand.java @@ -1,13 +1,14 @@ -package org.samo_lego.taterzens.commands; +package org.samo_lego.taterzens.common.commands; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.commands.CommandSourceStack; import net.minecraft.server.level.ServerPlayer; -import org.samo_lego.taterzens.Taterzens; +import org.samo_lego.taterzens.common.Taterzens; + +import static org.samo_lego.taterzens.common.commands.NpcCommand.npcNode; -import static org.samo_lego.taterzens.commands.NpcCommand.npcNode; public class NpcGUICommand { diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/PresetCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/PresetCommand.java similarity index 86% rename from common/src/main/java/org/samo_lego/taterzens/commands/PresetCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/PresetCommand.java index c7aa8e31e..5adcd643b 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/PresetCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/PresetCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands; +package org.samo_lego.taterzens.common.commands; import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.context.CommandContext; @@ -8,20 +8,20 @@ import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.api.TaterzensAPI; -import org.samo_lego.taterzens.interfaces.ITaterzenEditor; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.api.TaterzensAPI; +import org.samo_lego.taterzens.common.interfaces.ITaterzenEditor; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.io.File; import static com.mojang.brigadier.arguments.StringArgumentType.word; import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.api.TaterzensAPI.getPresets; -import static org.samo_lego.taterzens.util.TextUtil.errorText; -import static org.samo_lego.taterzens.util.TextUtil.successText; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.api.TaterzensAPI.getPresets; +import static org.samo_lego.taterzens.common.util.TextUtil.errorText; +import static org.samo_lego.taterzens.common.util.TextUtil.successText; public class PresetCommand { public static void registerNode(LiteralCommandNode npcNode) { @@ -60,7 +60,7 @@ private static int loadTaterzenFromPreset(CommandContext con ((ITaterzenEditor) source.getPlayerOrException()).selectNpc(taterzenNPC); - taterzenNPC.sendProfileUpdates(); + taterzenNPC.broadcastProfileUpdates(); source.sendSuccess(() -> successText("taterzens.command.preset.import.success", filename), diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/ProfessionCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/ProfessionCommand.java similarity index 85% rename from common/src/main/java/org/samo_lego/taterzens/commands/ProfessionCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/ProfessionCommand.java index fcbe3d566..3b8131ead 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/ProfessionCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/ProfessionCommand.java @@ -1,12 +1,12 @@ -package org.samo_lego.taterzens.commands; +package org.samo_lego.taterzens.common.commands; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.tree.LiteralCommandNode; import net.minecraft.commands.CommandSourceStack; -import org.samo_lego.taterzens.Taterzens; +import org.samo_lego.taterzens.common.Taterzens; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.config; +import static org.samo_lego.taterzens.common.Taterzens.config; public class ProfessionCommand { public static final LiteralCommandNode PROFESSION_COMMAND_NODE; diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/TaterzensCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/TaterzensCommand.java similarity index 90% rename from common/src/main/java/org/samo_lego/taterzens/commands/TaterzensCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/TaterzensCommand.java index 359d2ad59..74e6d8a54 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/TaterzensCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/TaterzensCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands; +package org.samo_lego.taterzens.common.commands; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.StringArgumentType; @@ -13,17 +13,17 @@ import net.minecraft.network.chat.HoverEvent; import net.minecraft.resources.ResourceLocation; import org.samo_lego.config2brigadier.util.TranslatedText; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.util.LanguageUtil; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.util.LanguageUtil; import static com.mojang.brigadier.arguments.StringArgumentType.word; import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.MOD_ID; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.compatibility.ModDiscovery.SERVER_TRANSLATIONS_LOADED; -import static org.samo_lego.taterzens.util.LanguageUtil.LANG_LIST; -import static org.samo_lego.taterzens.util.TextUtil.*; +import static org.samo_lego.taterzens.common.Taterzens.MOD_ID; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.compatibility.ModDiscovery.SERVER_TRANSLATIONS_LOADED; +import static org.samo_lego.taterzens.common.util.LanguageUtil.LANG_LIST; +import static org.samo_lego.taterzens.common.util.TextUtil.*; public class TaterzensCommand { private static final SuggestionProvider AVAILABLE_LANGUAGES; @@ -133,7 +133,7 @@ private static void reloadConfig() { static { AVAILABLE_LANGUAGES = SuggestionProviders.register( - new ResourceLocation(MOD_ID, "languages"), + ResourceLocation.fromNamespaceAndPath(MOD_ID, "languages"), (context, builder) -> SharedSuggestionProvider.suggest(LANG_LIST, builder) ); diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/TeleportCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/TeleportCommand.java similarity index 82% rename from common/src/main/java/org/samo_lego/taterzens/commands/TeleportCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/TeleportCommand.java index db1993fe1..49fcae536 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/TeleportCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/TeleportCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands; +package org.samo_lego.taterzens.common.commands; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -7,15 +7,18 @@ import net.minecraft.commands.arguments.EntityArgument; import net.minecraft.commands.arguments.coordinates.Vec3Argument; import net.minecraft.world.phys.Vec3; -import org.samo_lego.taterzens.Taterzens; +import org.samo_lego.taterzens.common.Taterzens; import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.commands.NpcCommand.selectedTaterzenExecutor; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.commands.NpcCommand.selectedTaterzenExecutor; public class TeleportCommand { + // TODO: Fix this implementation to match up with the 1.21 Teleport implementation + + /* public static void registerNode(LiteralCommandNode npcNode) { LiteralCommandNode tpNode = literal("tp") .requires(src -> Taterzens.getInstance().getPlatform().checkPermission(src, "taterzens.npc.tp", config.perms.npcCommandPermissionLevel)) @@ -29,9 +32,12 @@ public static void registerNode(LiteralCommandNode npcNode) npcNode.addChild(tpNode); } + */ + /* private static int teleportTaterzen(CommandContext context, Vec3 destination) throws CommandSyntaxException { CommandSourceStack source = context.getSource(); return selectedTaterzenExecutor(source.getEntityOrException(), taterzen -> taterzen.teleportToWithTicket(destination.x(), destination.y(), destination.z())); } + */ } diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/BehaviourCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/BehaviourCommand.java similarity index 85% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/BehaviourCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/BehaviourCommand.java index bcccbd491..9103e360c 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/BehaviourCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/BehaviourCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands.edit; +package org.samo_lego.taterzens.common.commands.edit; import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.context.CommandContext; @@ -12,9 +12,9 @@ import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.HoverEvent; import net.minecraft.resources.ResourceLocation; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.commands.NpcCommand; -import org.samo_lego.taterzens.npc.NPCData; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.commands.NpcCommand; +import org.samo_lego.taterzens.common.npc.NPCData; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -22,10 +22,10 @@ import static com.mojang.brigadier.arguments.StringArgumentType.word; import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.MOD_ID; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.successText; -import static org.samo_lego.taterzens.util.TextUtil.translate; +import static org.samo_lego.taterzens.common.Taterzens.MOD_ID; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.successText; +import static org.samo_lego.taterzens.common.util.TextUtil.translate; public class BehaviourCommand { @@ -64,7 +64,7 @@ private static int setTaterzenBehaviour(CommandContext conte static { HOSTILITY_TYPES = SuggestionProviders.register( - new ResourceLocation(MOD_ID, "hostility_types"), + ResourceLocation.fromNamespaceAndPath(MOD_ID, "hostility_types"), (context, builder) -> SharedSuggestionProvider.suggest(Stream.of(NPCData.Behaviour.values()).map(Enum::name).collect(Collectors.toList()), builder) ); diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/EditCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/EditCommand.java similarity index 86% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/EditCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/EditCommand.java index b653aa135..90f9e46a7 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/EditCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/EditCommand.java @@ -1,11 +1,11 @@ -package org.samo_lego.taterzens.commands.edit; +package org.samo_lego.taterzens.common.commands.edit; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.tree.LiteralCommandNode; import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandSourceStack; -import org.samo_lego.taterzens.commands.edit.commands.CommandsCommand; -import org.samo_lego.taterzens.commands.edit.messages.MessagesCommand; +import org.samo_lego.taterzens.common.commands.edit.messages.MessagesCommand; +import org.samo_lego.taterzens.common.commands.edit.commands.CommandsCommand; import static net.minecraft.commands.Commands.literal; diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/EquipmentCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/EquipmentCommand.java similarity index 92% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/EquipmentCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/EquipmentCommand.java index ff5d198fe..6f833f307 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/EquipmentCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/EquipmentCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands.edit; +package org.samo_lego.taterzens.common.commands.edit; import com.mojang.brigadier.arguments.BoolArgumentType; import com.mojang.brigadier.context.CommandContext; @@ -9,14 +9,14 @@ import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.HoverEvent; import net.minecraft.server.level.ServerPlayer; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.commands.NpcCommand; -import org.samo_lego.taterzens.interfaces.ITaterzenEditor; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.commands.NpcCommand; +import org.samo_lego.taterzens.common.interfaces.ITaterzenEditor; import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.*; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.*; public class EquipmentCommand { diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/MountCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/MountCommand.java similarity index 79% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/MountCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/MountCommand.java index 79c1889a2..24b830232 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/MountCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/MountCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands.edit; +package org.samo_lego.taterzens.common.commands.edit; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -7,13 +7,14 @@ import net.minecraft.commands.arguments.EntityArgument; import net.minecraft.network.chat.MutableComponent; import net.minecraft.world.entity.Entity; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.commands.NpcCommand; +import org.samo_lego.taterzens.common.commands.NpcCommand; +import org.samo_lego.taterzens.common.util.TextUtil; +import org.samo_lego.taterzens.common.Taterzens; import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.successText; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.successText; public class MountCommand { public static void registerNode(LiteralCommandNode editNode) { @@ -42,12 +43,12 @@ public static int mountTaterzen(CommandContext context) thro MutableComponent feedbackText; if(finalToMount == null) { taterzen.stopRiding(); - feedbackText = successText("taterzens.command.umount", taterzen.getName().getString()); + feedbackText = TextUtil.successText("taterzens.command.umount", taterzen.getName().getString()); } else { taterzen.startRiding(finalToMount, true); feedbackText = successText("taterzens.command.mount", taterzen.getName().getString(), finalToMount.getName().getString()); } - taterzen.sendProfileUpdates(); + taterzen.broadcastProfileUpdates(); src.sendSuccess(() -> feedbackText, false); }); } diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/MovementCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/MovementCommand.java similarity index 89% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/MovementCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/MovementCommand.java index a9728922b..b4c950282 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/MovementCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/MovementCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands.edit; +package org.samo_lego.taterzens.common.commands.edit; import com.mojang.brigadier.arguments.BoolArgumentType; import com.mojang.brigadier.arguments.StringArgumentType; @@ -11,9 +11,9 @@ import net.minecraft.commands.arguments.EntityArgument; import net.minecraft.commands.synchronization.SuggestionProviders; import net.minecraft.resources.ResourceLocation; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.commands.NpcCommand; -import org.samo_lego.taterzens.npc.NPCData; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.commands.NpcCommand; +import org.samo_lego.taterzens.common.npc.NPCData; import java.util.UUID; import java.util.stream.Collectors; @@ -22,10 +22,10 @@ import static com.mojang.brigadier.arguments.StringArgumentType.word; import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.MOD_ID; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.errorText; -import static org.samo_lego.taterzens.util.TextUtil.successText; +import static org.samo_lego.taterzens.common.Taterzens.MOD_ID; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.errorText; +import static org.samo_lego.taterzens.common.util.TextUtil.successText; public class MovementCommand { @@ -99,13 +99,13 @@ private static int setFollowType(CommandContext context, NPC static { MOVEMENT_TYPES = SuggestionProviders.register( - new ResourceLocation(MOD_ID, "movement_types"), + ResourceLocation.fromNamespaceAndPath(MOD_ID, "movement_types"), (context, builder) -> SharedSuggestionProvider.suggest(Stream.of(NPCData.Movement.values()).map(Enum::name).collect(Collectors.toList()), builder) ); FOLLOW_TYPES = SuggestionProviders.register( - new ResourceLocation(MOD_ID, "follow_types"), + ResourceLocation.fromNamespaceAndPath(MOD_ID, "follow_types"), (context, builder) -> SharedSuggestionProvider.suggest(Stream.of(NPCData.FollowTypes.values()).map(Enum::name).collect(Collectors.toList()), builder) ); diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/NameCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/NameCommand.java similarity index 84% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/NameCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/NameCommand.java index f6ae3cae0..4c1cbc751 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/NameCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/NameCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands.edit; +package org.samo_lego.taterzens.common.commands.edit; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -6,14 +6,14 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.MessageArgument; import net.minecraft.network.chat.Component; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.commands.NpcCommand; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.commands.NpcCommand; import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; import static net.minecraft.commands.arguments.MessageArgument.message; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.successText; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.successText; public class NameCommand { diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/PathCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/PathCommand.java similarity index 92% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/PathCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/PathCommand.java index af895526b..b152cbf74 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/PathCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/PathCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands.edit; +package org.samo_lego.taterzens.common.commands.edit; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -11,13 +11,13 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.commands.NpcCommand; -import org.samo_lego.taterzens.interfaces.ITaterzenEditor; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.commands.NpcCommand; +import org.samo_lego.taterzens.common.interfaces.ITaterzenEditor; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.*; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.*; public class PathCommand { public static void registerNode(LiteralCommandNode editNode) { diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/PoseCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/PoseCommand.java similarity index 86% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/PoseCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/PoseCommand.java index b92070457..2244ee602 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/PoseCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/PoseCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands.edit; +package org.samo_lego.taterzens.common.commands.edit; import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.context.CommandContext; @@ -7,8 +7,8 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.world.entity.Pose; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.commands.NpcCommand; +import org.samo_lego.taterzens.common.commands.NpcCommand; +import org.samo_lego.taterzens.common.Taterzens; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -16,8 +16,8 @@ import static com.mojang.brigadier.arguments.StringArgumentType.word; import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.successText; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.successText; public class PoseCommand { public static void registerNode(LiteralCommandNode editNode) { diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/ProfessionsCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/ProfessionsCommand.java similarity index 91% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/ProfessionsCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/ProfessionsCommand.java index 07d127a9f..706c2be11 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/ProfessionsCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/ProfessionsCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands.edit; +package org.samo_lego.taterzens.common.commands.edit; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -15,10 +15,10 @@ import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.commands.NpcCommand; -import org.samo_lego.taterzens.interfaces.ITaterzenEditor; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.commands.NpcCommand; +import org.samo_lego.taterzens.common.interfaces.ITaterzenEditor; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.util.*; import java.util.concurrent.CompletableFuture; @@ -27,9 +27,9 @@ import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; import static net.minecraft.commands.arguments.MessageArgument.message; -import static org.samo_lego.taterzens.Taterzens.PROFESSION_TYPES; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.*; +import static org.samo_lego.taterzens.common.Taterzens.PROFESSION_TYPES; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.*; public class ProfessionsCommand { @@ -42,14 +42,14 @@ public static void registerNode(LiteralCommandNode editNode) .requires(src -> Taterzens.getInstance().getPlatform().checkPermission(src, "taterzens.npc.edit.professions.remove", config.perms.npcCommandPermissionLevel)) .then(argument("profession type", message()) .suggests(ProfessionsCommand::suggestRemovableProfessions) - .executes(ctx -> removeProfession(ctx, new ResourceLocation(MessageArgument.getMessage(ctx, "profession type").getString()))) + .executes(ctx -> removeProfession(ctx, ResourceLocation.parse(MessageArgument.getMessage(ctx, "profession type").getString()))) ) ) .then(literal("add") .requires(src -> Taterzens.getInstance().getPlatform().checkPermission(src, "taterzens.npc.edit.professions.add", config.perms.npcCommandPermissionLevel)) .then(argument("profession type", message()) .suggests(PROFESSION_SUGESTIONS) - .executes(ctx -> setProfession(ctx, new ResourceLocation(MessageArgument.getMessage(ctx, "profession type").getString()))) + .executes(ctx -> setProfession(ctx, ResourceLocation.parse(MessageArgument.getMessage(ctx, "profession type").getString()))) ) ) .then(literal("list") diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/RespawnPointCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/RespawnPointCommand.java similarity index 90% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/RespawnPointCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/RespawnPointCommand.java index a3f8d41aa..e9b699c6d 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/RespawnPointCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/RespawnPointCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands.edit; +package org.samo_lego.taterzens.common.commands.edit; import com.mojang.brigadier.arguments.BoolArgumentType; import com.mojang.brigadier.context.CommandContext; @@ -8,13 +8,13 @@ import net.minecraft.commands.arguments.coordinates.BlockPosArgument; import net.minecraft.core.BlockPos; import net.minecraft.world.phys.Vec3; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.commands.NpcCommand; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.commands.NpcCommand; import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.successText; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.successText; public class RespawnPointCommand { public static void registerNode(LiteralCommandNode editNode) { diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/SkinCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/SkinCommand.java similarity index 90% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/SkinCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/SkinCommand.java index 037ae3f4f..5fa4772b7 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/SkinCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/SkinCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands.edit; +package org.samo_lego.taterzens.common.commands.edit; import com.google.gson.JsonObject; import com.mojang.brigadier.context.CommandContext; @@ -12,8 +12,8 @@ import net.minecraft.network.chat.HoverEvent; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.commands.NpcCommand; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.commands.NpcCommand; import java.io.IOException; import java.net.MalformedURLException; @@ -24,12 +24,12 @@ import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; import static net.minecraft.commands.arguments.MessageArgument.message; -import static org.samo_lego.taterzens.Taterzens.GSON; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.compatibility.ModDiscovery.FABRICTAILOR_LOADED; -import static org.samo_lego.taterzens.mixin.accessors.APlayer.getPLAYER_MODE_CUSTOMISATION; -import static org.samo_lego.taterzens.util.TextUtil.*; -import static org.samo_lego.taterzens.util.WebUtil.urlRequest; +import static org.samo_lego.taterzens.common.Taterzens.GSON; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.compatibility.ModDiscovery.FABRICTAILOR_LOADED; +import static org.samo_lego.taterzens.common.mixin.accessors.APlayer.getPLAYER_MODE_CUSTOMISATION; +import static org.samo_lego.taterzens.common.util.TextUtil.*; +import static org.samo_lego.taterzens.common.util.WebUtil.urlRequest; public class SkinCommand { @@ -120,7 +120,7 @@ private static int setCustomSkin(CommandContext context) thr skinTag.putString("signature", signature); taterzen.setSkinFromTag(skinTag); - taterzen.sendProfileUpdates(); + taterzen.broadcastProfileUpdates(); context.getSource().sendSuccess(() -> @@ -147,7 +147,7 @@ private static int copySkinLayers(CommandContext context) th Byte skinLayers = player.getEntityData().get(getPLAYER_MODE_CUSTOMISATION()); taterzen.setSkinLayers(skinLayers); - taterzen.sendProfileUpdates(); + taterzen.broadcastProfileUpdates(); source.sendSuccess(() -> successText("taterzens.command.skin.mirrored", taterzen.getName().getString()), false diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/SoundCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/SoundCommand.java similarity index 98% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/SoundCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/SoundCommand.java index 47d9afd98..d94546a7b 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/SoundCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/SoundCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands.edit; +package org.samo_lego.taterzens.common.commands.edit; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.context.CommandContext; @@ -13,8 +13,8 @@ import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.commands.NpcCommand; +import org.samo_lego.taterzens.common.commands.NpcCommand; +import org.samo_lego.taterzens.common.Taterzens; import java.util.ArrayList; import java.util.concurrent.atomic.AtomicBoolean; @@ -22,8 +22,8 @@ import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.*; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.*; public class SoundCommand { @@ -565,7 +565,7 @@ private static int addAmbientSound(CommandContext context) t ServerPlayer player = source.getPlayerOrException(); String soundResource = ResourceLocationArgument.getId(context, "ambientSound").toString(); - if (!ResourceLocation.isValidResourceLocation(soundResource)) + if (!ResourceLocation.isValidNamespace(soundResource)) { source.sendFailure(errorText("taterzens.command.sounds.invalid")); return 0; @@ -592,7 +592,7 @@ private static int addHurtSound(CommandContext context) thro ServerPlayer player = source.getPlayerOrException(); String soundResource = ResourceLocationArgument.getId(context, "hurtSound").toString(); - if (!ResourceLocation.isValidResourceLocation(soundResource)) + if (!ResourceLocation.isValidNamespace(soundResource)) { source.sendFailure(errorText("taterzens.command.sounds.invalid")); return 0; @@ -618,7 +618,7 @@ private static int addDeathSound(CommandContext context) thr ServerPlayer player = source.getPlayerOrException(); String soundResource = ResourceLocationArgument.getId(context, "deathSound").toString(); - if (!ResourceLocation.isValidResourceLocation(soundResource)) + if (!ResourceLocation.isValidNamespace(soundResource)) { source.sendFailure(errorText("taterzens.command.sounds.invalid")); return 0; diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/TagsCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/TagsCommand.java similarity index 95% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/TagsCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/TagsCommand.java index 997a8c177..c05042a0a 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/TagsCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/TagsCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands.edit; +package org.samo_lego.taterzens.common.commands.edit; import com.mojang.brigadier.arguments.BoolArgumentType; import com.mojang.brigadier.context.CommandContext; @@ -8,17 +8,17 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.Pose; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.commands.NpcCommand; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.commands.NpcCommand; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.util.function.Consumer; import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.joinText; -import static org.samo_lego.taterzens.util.TextUtil.successText; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.joinText; +import static org.samo_lego.taterzens.common.util.TextUtil.successText; public class TagsCommand { public static void registerNode(LiteralCommandNode editNode) { diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/TypeCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/TypeCommand.java similarity index 79% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/TypeCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/TypeCommand.java index 7217276a3..035eafb3b 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/TypeCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/TypeCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands.edit; +package org.samo_lego.taterzens.common.commands.edit; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -15,18 +15,25 @@ import net.minecraft.network.chat.HoverEvent; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityType; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.commands.NpcCommand; +import org.samo_lego.taterzens.common.commands.NpcCommand; +import org.samo_lego.taterzens.common.Taterzens; import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; import static net.minecraft.commands.synchronization.SuggestionProviders.SUMMONABLE_ENTITIES; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.compatibility.ModDiscovery.DISGUISELIB_LOADED; -import static org.samo_lego.taterzens.util.TextUtil.successText; -import static org.samo_lego.taterzens.util.TextUtil.translate; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.compatibility.ModDiscovery.DISGUISELIB_LOADED; +import static org.samo_lego.taterzens.common.util.TextUtil.successText; +import static org.samo_lego.taterzens.common.util.TextUtil.translate; + +import org.samo_lego.taterzens.common.npc.NPCData; +import static org.apache.logging.log4j.LogManager.getLogger; + public class TypeCommand { + + public final NPCData npcData = new NPCData(); + public static void registerNode(LiteralCommandNode editNode, CommandBuildContext commandBuildContext) { LiteralCommandNode typeNode = literal("type") .requires(src -> Taterzens.getInstance().getPlatform().checkPermission(src, "taterzens.npc.edit.entity_type", config.perms.npcCommandPermissionLevel)) @@ -56,6 +63,8 @@ public static void registerNode(LiteralCommandNode editNode, private static int changeType(CommandContext context) throws CommandSyntaxException { CommandSourceStack source = context.getSource(); + /* + Commenting out for now, as polymer provides the interface for setting type. if (!DISGUISELIB_LOADED) { source.sendFailure(translate("advert.disguiselib.required") .withStyle(ChatFormatting.RED) @@ -66,7 +75,7 @@ private static int changeType(CommandContext context) throws ); return -1; } - + */ ResourceLocation disguise = ResourceArgument.getSummonableEntityType(context, "entity type").key().location(); return NpcCommand.selectedTaterzenExecutor(source.getEntityOrException(), taterzen -> { CompoundTag nbt; @@ -78,6 +87,19 @@ private static int changeType(CommandContext context) throws nbt.putString("id", disguise.toString()); EntityType.loadEntityRecursive(nbt, source.getLevel(), (entityx) -> { + // We can do some manipulation based on the detail returned + // taterzen.modEntity() is a short all-caps descriptor of the current TYPE. + var removeSub = "entity.minecraft."; + + var interim = entityx.getType().getDescriptionId(); + + + String stripped = interim.replace(removeSub, "").toUpperCase(); + + getLogger("Taterzens").info("[Taterzens]: Setting the order to change the type - {}", stripped); + + taterzen.modEntity(stripped); + Taterzens.getInstance().getPlatform().disguiseAs(taterzen, entityx); source.sendSuccess(() -> translate( @@ -93,7 +115,10 @@ private static int changeType(CommandContext context) throws private static int resetType(CommandContext context) throws CommandSyntaxException { CommandSourceStack source = context.getSource(); - if(!DISGUISELIB_LOADED) { + + /* + Commenting out for now, as polymer provides the interface for setting type. + if(!DISGUISELIB_LOADED) { source.sendFailure(translate("advert.disguiselib.required") .withStyle(ChatFormatting.RED) .withStyle(style -> style @@ -103,7 +128,13 @@ private static int resetType(CommandContext context) throws ); return -1; } + */ + return NpcCommand.selectedTaterzenExecutor(source.getEntityOrException(), taterzen -> { + + // The Reset is to PLAYER + taterzen.modEntity("PLAYER"); + Taterzens.getInstance().getPlatform().clearDisguise(taterzen); source.sendSuccess(() -> successText("taterzens.command.entity_type.reset", taterzen.getName().getString()), diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/commands/CommandsCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/commands/CommandsCommand.java similarity index 96% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/commands/CommandsCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/commands/CommandsCommand.java index 62a5dd335..7bdd28cd2 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/commands/CommandsCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/commands/CommandsCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands.edit.commands; +package org.samo_lego.taterzens.common.commands.edit.commands; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.IntegerArgumentType; @@ -17,10 +17,10 @@ import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.commands.NpcCommand; -import org.samo_lego.taterzens.npc.commands.BungeeCommand; -import org.samo_lego.taterzens.npc.commands.MinecraftCommand; +import org.samo_lego.taterzens.common.commands.NpcCommand; +import org.samo_lego.taterzens.common.npc.commands.BungeeCommand; +import org.samo_lego.taterzens.common.npc.commands.MinecraftCommand; +import org.samo_lego.taterzens.common.Taterzens; import java.util.Collection; import java.util.concurrent.atomic.AtomicReference; @@ -30,11 +30,11 @@ import static com.mojang.brigadier.arguments.StringArgumentType.string; import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.MOD_ID; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.commands.NpcCommand.noSelectedTaterzenError; -import static org.samo_lego.taterzens.npc.commands.BungeeCommand.AVAILABLE_SERVERS; -import static org.samo_lego.taterzens.util.TextUtil.*; +import static org.samo_lego.taterzens.common.Taterzens.MOD_ID; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.commands.NpcCommand.noSelectedTaterzenError; +import static org.samo_lego.taterzens.common.npc.commands.BungeeCommand.AVAILABLE_SERVERS; +import static org.samo_lego.taterzens.common.util.TextUtil.*; public class CommandsCommand { private static final SuggestionProvider BUNGEE_COMMANDS; @@ -399,12 +399,12 @@ private static String addCommand(CommandContext context) thr static { BUNGEE_COMMANDS = SuggestionProviders.register( - new ResourceLocation(MOD_ID, "bungee_commands"), + ResourceLocation.fromNamespaceAndPath(MOD_ID, "bungee_commands"), (context, builder) -> SharedSuggestionProvider.suggest(Stream.of(BungeeCommand.BungeeMessage.values()).map(cmd -> cmd.toString().toLowerCase()).collect(Collectors.toList()), builder) ); PLAYERS = SuggestionProviders.register( - new ResourceLocation(MOD_ID, "players"), + ResourceLocation.fromNamespaceAndPath(MOD_ID, "players"), (context, builder) -> { Collection names = context.getSource().getOnlinePlayerNames(); names.add("--clicker--"); diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/commands/CooldownCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/commands/CooldownCommand.java similarity index 90% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/commands/CooldownCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/commands/CooldownCommand.java index 488b2169b..03e3d5b7b 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/commands/CooldownCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/commands/CooldownCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands.edit.commands; +package org.samo_lego.taterzens.common.commands.edit.commands; import com.mojang.brigadier.arguments.LongArgumentType; import com.mojang.brigadier.context.CommandContext; @@ -7,13 +7,13 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.MessageArgument; import net.minecraft.world.entity.Entity; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.commands.NpcCommand; +import org.samo_lego.taterzens.common.commands.NpcCommand; +import org.samo_lego.taterzens.common.Taterzens; import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.successText; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.successText; public class CooldownCommand { diff --git a/common/src/main/java/org/samo_lego/taterzens/commands/edit/messages/MessagesCommand.java b/src/main/java/org/samo_lego/taterzens/common/commands/edit/messages/MessagesCommand.java similarity index 97% rename from common/src/main/java/org/samo_lego/taterzens/commands/edit/messages/MessagesCommand.java rename to src/main/java/org/samo_lego/taterzens/common/commands/edit/messages/MessagesCommand.java index 3f70ebc37..568b6a43c 100644 --- a/common/src/main/java/org/samo_lego/taterzens/commands/edit/messages/MessagesCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/commands/edit/messages/MessagesCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.commands.edit.messages; +package org.samo_lego.taterzens.common.commands.edit.messages; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.context.CommandContext; @@ -12,9 +12,9 @@ import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.MutableComponent; import net.minecraft.server.level.ServerPlayer; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.commands.NpcCommand; -import org.samo_lego.taterzens.interfaces.ITaterzenEditor; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.commands.NpcCommand; +import org.samo_lego.taterzens.common.interfaces.ITaterzenEditor; import java.util.ArrayList; import java.util.List; @@ -22,8 +22,8 @@ import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.*; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.*; public class MessagesCommand { public static LiteralCommandNode messagesNode; diff --git a/common/src/main/java/org/samo_lego/taterzens/compatibility/ModDiscovery.java b/src/main/java/org/samo_lego/taterzens/common/compatibility/ModDiscovery.java similarity index 88% rename from common/src/main/java/org/samo_lego/taterzens/compatibility/ModDiscovery.java rename to src/main/java/org/samo_lego/taterzens/common/compatibility/ModDiscovery.java index 011db8d33..50747de5d 100644 --- a/common/src/main/java/org/samo_lego/taterzens/compatibility/ModDiscovery.java +++ b/src/main/java/org/samo_lego/taterzens/common/compatibility/ModDiscovery.java @@ -1,6 +1,6 @@ -package org.samo_lego.taterzens.compatibility; +package org.samo_lego.taterzens.common.compatibility; -import org.samo_lego.taterzens.platform.Platform; +import org.samo_lego.taterzens.common.platform.Platform; public class ModDiscovery { diff --git a/common/src/main/java/org/samo_lego/taterzens/event/BlockEvent.java b/src/main/java/org/samo_lego/taterzens/common/event/BlockEvent.java similarity index 86% rename from common/src/main/java/org/samo_lego/taterzens/event/BlockEvent.java rename to src/main/java/org/samo_lego/taterzens/common/event/BlockEvent.java index 67f9eb796..145dfe42e 100644 --- a/common/src/main/java/org/samo_lego/taterzens/event/BlockEvent.java +++ b/src/main/java/org/samo_lego/taterzens/common/event/BlockEvent.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.event; +package org.samo_lego.taterzens.common.event; import net.minecraft.core.BlockPos; import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; @@ -6,13 +6,14 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; -import org.samo_lego.taterzens.interfaces.ITaterzenEditor; +import org.samo_lego.taterzens.common.interfaces.ITaterzenEditor; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; public class BlockEvent { /** * Used if player is in path edit mode. Interacted blocks are removed from the path - * of selected {@link org.samo_lego.taterzens.npc.TaterzenNPC}. + * of selected {@link TaterzenNPC}. * * @param Player player breaking the block. * @param world world where block is being broken. diff --git a/common/src/main/java/org/samo_lego/taterzens/interfaces/ITaterzenEditor.java b/src/main/java/org/samo_lego/taterzens/common/interfaces/ITaterzenEditor.java similarity index 85% rename from common/src/main/java/org/samo_lego/taterzens/interfaces/ITaterzenEditor.java rename to src/main/java/org/samo_lego/taterzens/common/interfaces/ITaterzenEditor.java index 9844f816b..d8d187b7a 100644 --- a/common/src/main/java/org/samo_lego/taterzens/interfaces/ITaterzenEditor.java +++ b/src/main/java/org/samo_lego/taterzens/common/interfaces/ITaterzenEditor.java @@ -1,7 +1,8 @@ -package org.samo_lego.taterzens.interfaces; +package org.samo_lego.taterzens.common.interfaces; import org.jetbrains.annotations.Nullable; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.npc.NPCData; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.util.Optional; @@ -40,7 +41,7 @@ default TaterzenNPC getNpc() { /** * Sets the index of message that's * being edited by the player. - * Range: 0 - (size of {@link org.samo_lego.taterzens.npc.NPCData#messages} array - 1) + * Range: 0 - (size of {@link NPCData#messages} array - 1) * @param selected selected message in the messages array */ void setEditingMessageIndex(int selected); @@ -49,7 +50,7 @@ default TaterzenNPC getNpc() { * Gets the index of the message * player is editing for selected * {@link TaterzenNPC}. - * @return index of message being edited in {@link org.samo_lego.taterzens.npc.NPCData#messages} + * @return index of message being edited in {@link NPCData#messages} */ int getEditingMessageIndex(); diff --git a/common/src/main/java/org/samo_lego/taterzens/interfaces/ITaterzenPlayer.java b/src/main/java/org/samo_lego/taterzens/common/interfaces/ITaterzenPlayer.java similarity index 77% rename from common/src/main/java/org/samo_lego/taterzens/interfaces/ITaterzenPlayer.java rename to src/main/java/org/samo_lego/taterzens/common/interfaces/ITaterzenPlayer.java index cb3b9f6ca..63ea4473c 100644 --- a/common/src/main/java/org/samo_lego/taterzens/interfaces/ITaterzenPlayer.java +++ b/src/main/java/org/samo_lego/taterzens/common/interfaces/ITaterzenPlayer.java @@ -1,4 +1,7 @@ -package org.samo_lego.taterzens.interfaces; +package org.samo_lego.taterzens.common.interfaces; + +import org.samo_lego.taterzens.common.npc.NPCData; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.util.UUID; @@ -8,7 +11,7 @@ public interface ITaterzenPlayer { /** * Gets the last time player has interacted with - * {@link org.samo_lego.taterzens.npc.TaterzenNPC}. + * {@link TaterzenNPC}. * Used to prevent double triggering of * right-click actions. * @@ -18,7 +21,7 @@ public interface ITaterzenPlayer { /** * Sets last interaction time - * with {@link org.samo_lego.taterzens.npc.TaterzenNPC}. + * with {@link TaterzenNPC}. * @param time current player interaction time */ void setLastInteraction(long time); @@ -33,14 +36,14 @@ public interface ITaterzenPlayer { /** * Resets ticks since player got the last message - * from {@link org.samo_lego.taterzens.npc.TaterzenNPC}. + * from {@link TaterzenNPC}. * @param taterzenUuid uuid of taterzen to get msg pos for */ void resetMessageTicks(UUID taterzenUuid); /** * Gets last message position in - * {@link org.samo_lego.taterzens.npc.NPCData#messages array of messages}. + * {@link NPCData#messages array of messages}. * @param taterzenUuid uuid of taterzen to get msg pos for * @return last message index */ @@ -48,7 +51,7 @@ public interface ITaterzenPlayer { /** * Sets the index of last message in - * {@link org.samo_lego.taterzens.npc.NPCData#messages array of messages}. + * {@link NPCData#messages array of messages}. * @param taterzenUuid uuid of taterzen to get msg pos for * @param newPos new index for the last sent message. */ diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/ChunkMapMixin_TaterzenList.java b/src/main/java/org/samo_lego/taterzens/common/mixin/ChunkMapMixin_TaterzenList.java similarity index 75% rename from common/src/main/java/org/samo_lego/taterzens/mixin/ChunkMapMixin_TaterzenList.java rename to src/main/java/org/samo_lego/taterzens/common/mixin/ChunkMapMixin_TaterzenList.java index ebba11bf3..ff725473e 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/ChunkMapMixin_TaterzenList.java +++ b/src/main/java/org/samo_lego/taterzens/common/mixin/ChunkMapMixin_TaterzenList.java @@ -1,20 +1,21 @@ -package org.samo_lego.taterzens.mixin; +package org.samo_lego.taterzens.common.mixin; import net.minecraft.server.level.ChunkMap; import net.minecraft.world.entity.Entity; -import org.samo_lego.taterzens.npc.TaterzenNPC; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; -import static org.samo_lego.taterzens.Taterzens.TATERZEN_NPCS; +import static org.samo_lego.taterzens.common.Taterzens.TATERZEN_NPCS; @Mixin(ChunkMap.class) public class ChunkMapMixin_TaterzenList { /** - * Sets Taterzen to {@link org.samo_lego.taterzens.Taterzens#TATERZEN_NPCS NPC list}. + * Sets Taterzen to {@link Taterzens#TATERZEN_NPCS NPC list}. * @param entity entity being loaded */ @Inject(method = "addEntity(Lnet/minecraft/world/entity/Entity;)V", at = @At("TAIL")) @@ -25,7 +26,7 @@ private void onEntityAdded(Entity entity, CallbackInfo ci) { } /** - * Unloads Taterzen from {@link org.samo_lego.taterzens.Taterzens#TATERZEN_NPCS NPC list}. + * Unloads Taterzen from {@link Taterzens#TATERZEN_NPCS NPC list}. * @param entity entity being unloaded */ @Inject(method = "removeEntity(Lnet/minecraft/world/entity/Entity;)V", at = @At("TAIL")) diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/CommandSourceStackMixin_HideTaterzenExecutor.java b/src/main/java/org/samo_lego/taterzens/common/mixin/CommandSourceStackMixin_HideTaterzenExecutor.java similarity index 78% rename from common/src/main/java/org/samo_lego/taterzens/mixin/CommandSourceStackMixin_HideTaterzenExecutor.java rename to src/main/java/org/samo_lego/taterzens/common/mixin/CommandSourceStackMixin_HideTaterzenExecutor.java index a5622db5d..afabf77a8 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/CommandSourceStackMixin_HideTaterzenExecutor.java +++ b/src/main/java/org/samo_lego/taterzens/common/mixin/CommandSourceStackMixin_HideTaterzenExecutor.java @@ -1,18 +1,19 @@ -package org.samo_lego.taterzens.mixin; +package org.samo_lego.taterzens.common.mixin; import net.minecraft.commands.CommandSourceStack; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.Entity; import org.jetbrains.annotations.Nullable; -import org.samo_lego.taterzens.npc.TaterzenNPC; 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.samo_lego.taterzens.common.npc.TaterzenNPC; + +import static org.samo_lego.taterzens.common.Taterzens.config; -import static org.samo_lego.taterzens.Taterzens.config; @Mixin(CommandSourceStack.class) public class CommandSourceStackMixin_HideTaterzenExecutor { @@ -22,7 +23,7 @@ public class CommandSourceStackMixin_HideTaterzenExecutor { at = @At("HEAD"), cancellable = true) public void cancelSendingToOps(Component message, CallbackInfo ci) { - if(this.entity instanceof TaterzenNPC && config.hideOpsMessage) { + if (this.entity instanceof TaterzenNPC && config.hideOpsMessage) { ci.cancel(); } } diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/ServerPlayInteractionManagerMixin.java b/src/main/java/org/samo_lego/taterzens/common/mixin/ServerPlayInteractionManagerMixin.java similarity index 90% rename from common/src/main/java/org/samo_lego/taterzens/mixin/ServerPlayInteractionManagerMixin.java rename to src/main/java/org/samo_lego/taterzens/common/mixin/ServerPlayInteractionManagerMixin.java index 0255bdce6..9a8efacf2 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/ServerPlayInteractionManagerMixin.java +++ b/src/main/java/org/samo_lego/taterzens/common/mixin/ServerPlayInteractionManagerMixin.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.mixin; +package org.samo_lego.taterzens.common.mixin; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -7,13 +7,14 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayerGameMode; import net.minecraft.world.level.block.Blocks; -import org.samo_lego.taterzens.interfaces.ITaterzenEditor; +import org.samo_lego.taterzens.common.interfaces.ITaterzenEditor; 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.samo_lego.taterzens.common.npc.TaterzenNPC; @Mixin(ServerPlayerGameMode.class) public class ServerPlayInteractionManagerMixin { @@ -24,7 +25,7 @@ public class ServerPlayInteractionManagerMixin { /** * Used for detecting block breaking. Broken blocks count as new nodes - * for the path of player's {@link org.samo_lego.taterzens.npc.TaterzenNPC}. + * for the path of player's {@link TaterzenNPC}. * Activated only if player is in path edit mode and has a selected Taterzen. * * @param blockPos position of the broken block diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/accessors/AChunkMap.java b/src/main/java/org/samo_lego/taterzens/common/mixin/accessors/AChunkMap.java similarity index 85% rename from common/src/main/java/org/samo_lego/taterzens/mixin/accessors/AChunkMap.java rename to src/main/java/org/samo_lego/taterzens/common/mixin/accessors/AChunkMap.java index edfdfb202..61276c4a5 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/accessors/AChunkMap.java +++ b/src/main/java/org/samo_lego/taterzens/common/mixin/accessors/AChunkMap.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.mixin.accessors; +package org.samo_lego.taterzens.common.mixin.accessors; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import net.minecraft.server.level.ChunkMap; diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/accessors/AClientboundPlayerInfoPacket.java b/src/main/java/org/samo_lego/taterzens/common/mixin/accessors/AClientboundPlayerInfoPacket.java similarity index 88% rename from common/src/main/java/org/samo_lego/taterzens/mixin/accessors/AClientboundPlayerInfoPacket.java rename to src/main/java/org/samo_lego/taterzens/common/mixin/accessors/AClientboundPlayerInfoPacket.java index 7d4213784..a5a1dc926 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/accessors/AClientboundPlayerInfoPacket.java +++ b/src/main/java/org/samo_lego/taterzens/common/mixin/accessors/AClientboundPlayerInfoPacket.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.mixin.accessors; +package org.samo_lego.taterzens.common.mixin.accessors; import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket; import org.spongepowered.asm.mixin.Mixin; diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/accessors/AClientboundPlayerInfoUpdatePacket.java b/src/main/java/org/samo_lego/taterzens/common/mixin/accessors/AClientboundPlayerInfoUpdatePacket.java similarity index 89% rename from common/src/main/java/org/samo_lego/taterzens/mixin/accessors/AClientboundPlayerInfoUpdatePacket.java rename to src/main/java/org/samo_lego/taterzens/common/mixin/accessors/AClientboundPlayerInfoUpdatePacket.java index d225abb14..58566977a 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/accessors/AClientboundPlayerInfoUpdatePacket.java +++ b/src/main/java/org/samo_lego/taterzens/common/mixin/accessors/AClientboundPlayerInfoUpdatePacket.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.mixin.accessors; +package org.samo_lego.taterzens.common.mixin.accessors; import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket; import org.spongepowered.asm.mixin.Mixin; diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/accessors/AClientboundSetEntityDataPacket.java b/src/main/java/org/samo_lego/taterzens/common/mixin/accessors/AClientboundSetEntityDataPacket.java similarity index 90% rename from common/src/main/java/org/samo_lego/taterzens/mixin/accessors/AClientboundSetEntityDataPacket.java rename to src/main/java/org/samo_lego/taterzens/common/mixin/accessors/AClientboundSetEntityDataPacket.java index eccd96619..a0c108917 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/accessors/AClientboundSetEntityDataPacket.java +++ b/src/main/java/org/samo_lego/taterzens/common/mixin/accessors/AClientboundSetEntityDataPacket.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.mixin.accessors; +package org.samo_lego.taterzens.common.mixin.accessors; import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket; import net.minecraft.network.syncher.SynchedEntityData; diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/accessors/ACommandSourceStack.java b/src/main/java/org/samo_lego/taterzens/common/mixin/accessors/ACommandSourceStack.java similarity index 83% rename from common/src/main/java/org/samo_lego/taterzens/mixin/accessors/ACommandSourceStack.java rename to src/main/java/org/samo_lego/taterzens/common/mixin/accessors/ACommandSourceStack.java index 8682c0f9b..3933d1aaf 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/accessors/ACommandSourceStack.java +++ b/src/main/java/org/samo_lego/taterzens/common/mixin/accessors/ACommandSourceStack.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.mixin.accessors; +package org.samo_lego.taterzens.common.mixin.accessors; import net.minecraft.commands.CommandSourceStack; import org.spongepowered.asm.mixin.Mixin; diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/accessors/AEntityTrackerEntry.java b/src/main/java/org/samo_lego/taterzens/common/mixin/accessors/AEntityTrackerEntry.java similarity index 89% rename from common/src/main/java/org/samo_lego/taterzens/mixin/accessors/AEntityTrackerEntry.java rename to src/main/java/org/samo_lego/taterzens/common/mixin/accessors/AEntityTrackerEntry.java index 616b2a780..9a2f6b2b3 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/accessors/AEntityTrackerEntry.java +++ b/src/main/java/org/samo_lego/taterzens/common/mixin/accessors/AEntityTrackerEntry.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.mixin.accessors; +package org.samo_lego.taterzens.common.mixin.accessors; import net.minecraft.server.level.ServerEntity; import net.minecraft.server.network.ServerPlayerConnection; diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/accessors/APlayer.java b/src/main/java/org/samo_lego/taterzens/common/mixin/accessors/APlayer.java similarity index 87% rename from common/src/main/java/org/samo_lego/taterzens/mixin/accessors/APlayer.java rename to src/main/java/org/samo_lego/taterzens/common/mixin/accessors/APlayer.java index fb5977f6c..b15addf7b 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/accessors/APlayer.java +++ b/src/main/java/org/samo_lego/taterzens/common/mixin/accessors/APlayer.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.mixin.accessors; +package org.samo_lego.taterzens.common.mixin.accessors; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.world.entity.player.Player; diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_BungeeListener.java b/src/main/java/org/samo_lego/taterzens/common/mixin/network/ServerGamePacketListenerImplMixin_BungeeListener.java similarity index 72% rename from common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_BungeeListener.java rename to src/main/java/org/samo_lego/taterzens/common/mixin/network/ServerGamePacketListenerImplMixin_BungeeListener.java index e168d0c89..177f791fd 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_BungeeListener.java +++ b/src/main/java/org/samo_lego/taterzens/common/mixin/network/ServerGamePacketListenerImplMixin_BungeeListener.java @@ -1,36 +1,19 @@ -package org.samo_lego.taterzens.mixin.network; +package org.samo_lego.taterzens.common.mixin.network; -import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; -import net.minecraft.commands.CommandSourceStack; import net.minecraft.network.Connection; -import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket; -import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.CommonListenerCookie; import net.minecraft.server.network.ServerCommonPacketListenerImpl; import net.minecraft.server.network.ServerGamePacketListenerImpl; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.npc.commands.BungeeCommand; 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 java.util.Collections; - -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.npc.commands.BungeeCommand.AVAILABLE_SERVERS; -import static org.samo_lego.taterzens.npc.commands.BungeeCommand.BUNGEE_CHANNEL; /** * Handles bungee packets. */ -@Mixin(value = ServerGamePacketListenerImpl.class) +@Mixin(ServerGamePacketListenerImpl.class) public abstract class ServerGamePacketListenerImplMixin_BungeeListener extends ServerCommonPacketListenerImpl { @Unique private static final String GET_SERVERS = "GetServers"; @@ -44,7 +27,8 @@ public ServerGamePacketListenerImplMixin_BungeeListener(MinecraftServer minecraf super(minecraftServer, connection, commonListenerCookie); } - @Inject(method = "handleCustomPayload", at = @At("TAIL")) + // todo + /*@Inject(method = "handleCustomPayload", at = @At("TAIL")) private void taterzens_onCustomPayload(ServerboundCustomPayloadPacket packet, CallbackInfo ci) { ResourceLocation packetId = packet.payload().id(); CommandSourceStack commandSourceStack = player.createCommandSourceStack(); @@ -74,5 +58,5 @@ private void taterzens_onCustomPayload(ServerboundCustomPayloadPacket packet, Ca BungeeCommand.sendProxyPacket((ServerGamePacketListenerImpl) (Object) this, out.toByteArray()); } } - } + }*/ } diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_MsgEditor.java b/src/main/java/org/samo_lego/taterzens/common/mixin/network/ServerGamePacketListenerImplMixin_MsgEditor.java similarity index 90% rename from common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_MsgEditor.java rename to src/main/java/org/samo_lego/taterzens/common/mixin/network/ServerGamePacketListenerImplMixin_MsgEditor.java index 7ee30c6e1..344fbd621 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_MsgEditor.java +++ b/src/main/java/org/samo_lego/taterzens/common/mixin/network/ServerGamePacketListenerImplMixin_MsgEditor.java @@ -1,14 +1,13 @@ -package org.samo_lego.taterzens.mixin.network; +package org.samo_lego.taterzens.common.mixin.network; import com.google.gson.JsonParseException; -import com.mojang.brigadier.StringReader; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.ChatType; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.PlayerChatMessage; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.players.PlayerList; -import org.samo_lego.taterzens.interfaces.ITaterzenEditor; +import org.samo_lego.taterzens.common.interfaces.ITaterzenEditor; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -16,9 +15,9 @@ import java.util.function.Predicate; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.successText; -import static org.samo_lego.taterzens.util.TextUtil.translate; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.successText; +import static org.samo_lego.taterzens.common.util.TextUtil.translate; @Mixin(PlayerList.class) public class ServerGamePacketListenerImplMixin_MsgEditor { @@ -57,7 +56,7 @@ private void taterzens_chatBroadcast(PlayerChatMessage playerChatMessage, Predic if ((msg.startsWith("{") && msg.endsWith("}") || (msg.startsWith("[") && msg.endsWith("]")))) { // NBT tellraw message structure, try parse it try { - text = Component.Serializer.fromJson(new StringReader(msg)); + text = Component.Serializer.fromJson(msg, null); } catch (JsonParseException ignored) { player.displayClientMessage(translate("taterzens.error.invalid.text").withStyle(ChatFormatting.RED), false); ci.cancel(); @@ -88,4 +87,4 @@ private void taterzens_chatBroadcast(PlayerChatMessage playerChatMessage, Predic ci.cancel(); } } -} \ No newline at end of file +} diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/player/PlayerMixin_PeacefulDamage.java b/src/main/java/org/samo_lego/taterzens/common/mixin/player/PlayerMixin_PeacefulDamage.java similarity index 93% rename from common/src/main/java/org/samo_lego/taterzens/mixin/player/PlayerMixin_PeacefulDamage.java rename to src/main/java/org/samo_lego/taterzens/common/mixin/player/PlayerMixin_PeacefulDamage.java index 1dbf9a024..651f71809 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/player/PlayerMixin_PeacefulDamage.java +++ b/src/main/java/org/samo_lego/taterzens/common/mixin/player/PlayerMixin_PeacefulDamage.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.mixin.player; +package org.samo_lego.taterzens.common.mixin.player; import net.minecraft.world.Difficulty; import net.minecraft.world.damagesource.DamageSource; @@ -7,7 +7,7 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/player/ServerPlayerMixinCast_ITaterzenEditor.java b/src/main/java/org/samo_lego/taterzens/common/mixin/player/ServerPlayerMixinCast_ITaterzenEditor.java similarity index 92% rename from common/src/main/java/org/samo_lego/taterzens/mixin/player/ServerPlayerMixinCast_ITaterzenEditor.java rename to src/main/java/org/samo_lego/taterzens/common/mixin/player/ServerPlayerMixinCast_ITaterzenEditor.java index 2434ceed0..69822326d 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/player/ServerPlayerMixinCast_ITaterzenEditor.java +++ b/src/main/java/org/samo_lego/taterzens/common/mixin/player/ServerPlayerMixinCast_ITaterzenEditor.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.mixin.player; +package org.samo_lego.taterzens.common.mixin.player; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.DustParticleOptions; @@ -9,20 +9,20 @@ import net.minecraft.world.level.block.Blocks; import org.jetbrains.annotations.Nullable; import org.joml.Vector3f; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.interfaces.ITaterzenEditor; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.interfaces.ITaterzenEditor; 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 org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.util.ArrayList; import java.util.Optional; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.util.TextUtil.successText; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.util.TextUtil.successText; /** * Additional methods for players to track {@link TaterzenNPC} @@ -137,11 +137,11 @@ public boolean selectNpc(@Nullable TaterzenNPC npc) { this.selectedNpc = npc; if (npc != null) { - npc.sendProfileUpdates(); + npc.broadcastProfileUpdates(); } if (selectedNpc != null) { - selectedNpc.sendProfileUpdates(); + selectedNpc.broadcastProfileUpdates(); } return true; diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/player/ServerPlayerMixinCast_ITaterzenPlayer.java b/src/main/java/org/samo_lego/taterzens/common/mixin/player/ServerPlayerMixinCast_ITaterzenPlayer.java similarity index 91% rename from common/src/main/java/org/samo_lego/taterzens/mixin/player/ServerPlayerMixinCast_ITaterzenPlayer.java rename to src/main/java/org/samo_lego/taterzens/common/mixin/player/ServerPlayerMixinCast_ITaterzenPlayer.java index 278aedb2c..2d4c71bd1 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/player/ServerPlayerMixinCast_ITaterzenPlayer.java +++ b/src/main/java/org/samo_lego/taterzens/common/mixin/player/ServerPlayerMixinCast_ITaterzenPlayer.java @@ -1,18 +1,19 @@ -package org.samo_lego.taterzens.mixin.player; +package org.samo_lego.taterzens.common.mixin.player; import net.minecraft.server.level.ServerPlayer; -import org.samo_lego.taterzens.interfaces.ITaterzenPlayer; -import org.samo_lego.taterzens.npc.TaterzenNPC; 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 org.samo_lego.taterzens.common.interfaces.ITaterzenPlayer; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.util.HashMap; import java.util.UUID; -import static org.samo_lego.taterzens.Taterzens.config; +import static org.samo_lego.taterzens.common.Taterzens.config; + /** * Additional methods for players to track {@link TaterzenNPC} diff --git a/common/src/main/java/org/samo_lego/taterzens/npc/NPCData.java b/src/main/java/org/samo_lego/taterzens/common/npc/NPCData.java similarity index 86% rename from common/src/main/java/org/samo_lego/taterzens/npc/NPCData.java rename to src/main/java/org/samo_lego/taterzens/common/npc/NPCData.java index 52306727d..3ac307005 100644 --- a/common/src/main/java/org/samo_lego/taterzens/npc/NPCData.java +++ b/src/main/java/org/samo_lego/taterzens/common/npc/NPCData.java @@ -1,8 +1,9 @@ -package org.samo_lego.taterzens.npc; +package org.samo_lego.taterzens.common.npc; import com.mojang.datafixers.util.Pair; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.player.Player; import org.jetbrains.annotations.Nullable; @@ -11,7 +12,7 @@ import java.util.Map; import java.util.UUID; -import static org.samo_lego.taterzens.Taterzens.config; +import static org.samo_lego.taterzens.common.Taterzens.config; /** * Deafult NPC data. @@ -66,6 +67,7 @@ public class NPCData { public String commandCooldownMessage = config.defaults.commandCooldownMessage; public final Map booleanTags = new HashMap<>(); + public byte skinLayers = 127; public static class Follow { /** @@ -140,4 +142,11 @@ public enum FollowTypes { PLAYERS, MOBS } + + // We build a hashmap of entities to make our lives a little easier when changing and keeping TYPE + public HashMap> entityList = new HashMap<>(); + + // We set the player TYPE using a similar approach, since the data likes to be in a hashmap format. + public HashMap playerEntity = new HashMap<>(); + } diff --git a/common/src/main/java/org/samo_lego/taterzens/npc/TaterzenNPC.java b/src/main/java/org/samo_lego/taterzens/common/npc/TaterzenNPC.java similarity index 77% rename from common/src/main/java/org/samo_lego/taterzens/npc/TaterzenNPC.java rename to src/main/java/org/samo_lego/taterzens/common/npc/TaterzenNPC.java index 07e1bbb81..61c324d00 100644 --- a/common/src/main/java/org/samo_lego/taterzens/npc/TaterzenNPC.java +++ b/src/main/java/org/samo_lego/taterzens/common/npc/TaterzenNPC.java @@ -1,23 +1,26 @@ -package org.samo_lego.taterzens.npc; +package org.samo_lego.taterzens.common.npc; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.PropertyMap; import com.mojang.datafixers.util.Pair; +import eu.pb4.polymer.core.api.entity.PolymerEntity; +import eu.pb4.polymer.core.api.entity.PolymerEntityUtils; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.StringTag; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; -import net.minecraft.network.protocol.game.ClientGamePacketListener; -import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; +import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.level.*; +import net.minecraft.server.level.ChunkMap; +import net.minecraft.server.level.ServerChunkCache; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.util.Mth; @@ -39,7 +42,6 @@ import net.minecraft.world.entity.monster.CrossbowAttackMob; import net.minecraft.world.entity.monster.Monster; import net.minecraft.world.entity.monster.RangedAttackMob; -import net.minecraft.world.entity.player.ChatVisiblity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.entity.projectile.Projectile; @@ -47,41 +49,45 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.ProjectileWeaponItem; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; import net.minecraft.world.scores.PlayerTeam; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.joml.Vector3f; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.api.TaterzensAPI; -import org.samo_lego.taterzens.api.professions.TaterzenProfession; -import org.samo_lego.taterzens.interfaces.ITaterzenEditor; -import org.samo_lego.taterzens.interfaces.ITaterzenPlayer; -import org.samo_lego.taterzens.mixin.accessors.AChunkMap; -import org.samo_lego.taterzens.mixin.accessors.AEntityTrackerEntry; -import org.samo_lego.taterzens.npc.ai.goal.*; -import org.samo_lego.taterzens.npc.commands.AbstractTaterzenCommand; -import org.samo_lego.taterzens.npc.commands.CommandGroups; -import org.samo_lego.taterzens.util.TextUtil; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.api.TaterzensAPI; +import org.samo_lego.taterzens.common.api.professions.TaterzenProfession; +import org.samo_lego.taterzens.common.interfaces.ITaterzenEditor; +import org.samo_lego.taterzens.common.interfaces.ITaterzenPlayer; +import org.samo_lego.taterzens.common.mixin.accessors.AChunkMap; +import org.samo_lego.taterzens.common.mixin.accessors.AEntityTrackerEntry; +import org.samo_lego.taterzens.common.npc.NPCData; +import org.samo_lego.taterzens.common.npc.ai.goal.*; +import org.samo_lego.taterzens.common.npc.commands.AbstractTaterzenCommand; +import org.samo_lego.taterzens.common.npc.commands.CommandGroups; +import org.samo_lego.taterzens.common.util.TextUtil; import java.io.File; import java.util.*; +import java.util.function.Consumer; import java.util.function.Function; import static net.minecraft.world.InteractionHand.MAIN_HAND; -import static org.samo_lego.taterzens.Taterzens.*; -import static org.samo_lego.taterzens.mixin.accessors.APlayer.getPLAYER_MODE_CUSTOMISATION; -import static org.samo_lego.taterzens.util.TextUtil.errorText; -import static org.samo_lego.taterzens.util.TextUtil.successText; +import static org.samo_lego.taterzens.common.Taterzens.*; +import static org.samo_lego.taterzens.common.mixin.accessors.APlayer.getPLAYER_MODE_CUSTOMISATION; +import static org.samo_lego.taterzens.common.util.TextUtil.errorText; +import static org.samo_lego.taterzens.common.util.TextUtil.successText; + +import static org.apache.logging.log4j.LogManager.getLogger; /** * The NPC itself. */ -public class TaterzenNPC extends PathfinderMob implements CrossbowAttackMob, RangedAttackMob { +public class TaterzenNPC extends PathfinderMob implements CrossbowAttackMob, RangedAttackMob, PolymerEntity { /** * Data of the NPC. @@ -89,7 +95,6 @@ public class TaterzenNPC extends PathfinderMob implements CrossbowAttackMob, Ran private final NPCData npcData = new NPCData(); private final CommandGroups commandGroups; - private ServerPlayer fakePlayer; private final LinkedHashMap professions = new LinkedHashMap<>(); private GameProfile gameProfile; @@ -146,16 +151,17 @@ public TaterzenNPC(Level world) { /** * Creates a TaterzenNPC. * You'd probably want to use - * {@link org.samo_lego.taterzens.api.TaterzensAPI#createTaterzen(ServerLevel, String, Vec3, float[])} or - * {@link org.samo_lego.taterzens.api.TaterzensAPI#createTaterzen(ServerPlayer, String)} + * {@link TaterzensAPI#createTaterzen(ServerLevel, String, Vec3, float[])} or + * {@link TaterzensAPI#createTaterzen(ServerPlayer, String)} * instead, as this one doesn't set the position and custom name. * - * @param entityType Taterzen entity type + * @param npcData.entityList.put + Taterzen entity type * @param world Taterzen's world */ public TaterzenNPC(EntityType entityType, Level world) { super(entityType, world); - this.setMaxUpStep(0.6F); + // this.setMaxUpStep(0.6F); // Removed in 1.20.5 this.setCanPickUpLoot(true); this.setCustomNameVisible(true); this.setCustomName(this.getName()); @@ -167,10 +173,6 @@ public TaterzenNPC(EntityType entityType, Level world) this.gameProfile = new GameProfile(this.getUUID(), this.getName().getString()); this.commandGroups = new CommandGroups(this); - // Null check due top gravity changer incompatibility - if (this.fakePlayer == null) { - this.constructFakePlayer(); - } // Set the sounds of this NPC to the default values from the config file // (will be overwritten by individual configuration when e.g. loading corresponding NBT data) @@ -184,7 +186,160 @@ public TaterzenNPC(EntityType entityType, Level world) this.npcData.deathSounds = new ArrayList<>(config.defaults.deathSounds); } - } + // This is where the magic happens for changing entity type... + CompoundTag npcTag = new CompoundTag(); + if (npcTag.contains("Entity")) { + // Update it to the current settting + getLogger("Taterzens").info("[Taterzens]: We have a valid Entity setting and are putting it in the Tag - Map - {}, - Tag -", npcData.playerEntity.get("Entity"), npcTag.getString("Entity")); + // + npcTag.putString("Entity", npcData.playerEntity.get("Entity")); + // It's actually this we need to update since we have it stored, and the playerEntity hashmap is what we're using + npcData.playerEntity.put("Entity", npcTag.getString("Entity")); + } else { // Initial NPC creation we go to PLAYER + getLogger("Taterzens").info("[Taterzens]: No valid Entity set, so it's PLAYER time."); + + npcTag.putString("Entity", "PLAYER"); + npcData.playerEntity.put("Entity", "PLAYER"); + } + + // We only want to do this ONCE, and it gets fussy if placed anywhere else. + // So, we check to see if the list is empty and then fill it if it is + if (this.npcData.entityList.isEmpty()) { + + npcData.entityList.put("ALLAY", EntityType.ALLAY); + npcData.entityList.put("AREA_EFFECT_CLOUD", EntityType.AREA_EFFECT_CLOUD); + npcData.entityList.put("ARMOR_STAND", EntityType.ARMOR_STAND); + npcData.entityList.put("ARROW", EntityType.ARROW); + npcData.entityList.put("AXOLOTL", EntityType.AXOLOTL); + npcData.entityList.put("BAT", EntityType.BAT); + npcData.entityList.put("BEE", EntityType.BEE); + npcData.entityList.put("BLAZE", EntityType.BLAZE); + npcData.entityList.put("BLOCK_DISPLAY", EntityType.BLOCK_DISPLAY); + npcData.entityList.put("BOAT", EntityType.BOAT); + npcData.entityList.put("BREEZE", EntityType.BREEZE); + npcData.entityList.put("CAMEL", EntityType.CAMEL); + npcData.entityList.put("CAT", EntityType.CAT); + npcData.entityList.put("CAVE_SPIDER", EntityType.CAVE_SPIDER); + npcData.entityList.put("CHEST_BOAT", EntityType.CHEST_BOAT); + npcData.entityList.put("CHEST_MINECART", EntityType.CHEST_MINECART); + npcData.entityList.put("CHICKEN", EntityType.CHICKEN); + npcData.entityList.put("COD", EntityType.COD); + npcData.entityList.put("COMMAND_BLOCK_MINECART", EntityType.COMMAND_BLOCK_MINECART); + npcData.entityList.put("COW", EntityType.COW); + npcData.entityList.put("CREEPER", EntityType.CREEPER); + npcData.entityList.put("DOLPHIN", EntityType.DOLPHIN); + npcData.entityList.put("DONKEY", EntityType.DONKEY); + npcData.entityList.put("DRAGON_FIREBALL", EntityType.DRAGON_FIREBALL); + npcData.entityList.put("DROWNED", EntityType.DROWNED); + npcData.entityList.put("EGG", EntityType.EGG); + npcData.entityList.put("ELDER_GUARDIAN", EntityType.ELDER_GUARDIAN); + npcData.entityList.put("END_CRYSTAL", EntityType.END_CRYSTAL); + npcData.entityList.put("ENDER_DRAGON", EntityType.ENDER_DRAGON); + npcData.entityList.put("ENDER_PEARL", EntityType.ENDER_PEARL); + npcData.entityList.put("ENDERMAN", EntityType.ENDERMAN); + npcData.entityList.put("ENDERMITE", EntityType.ENDERMITE); + npcData.entityList.put("EVOKER", EntityType.EVOKER); + npcData.entityList.put("EVOKER_FANGS", EntityType.EVOKER_FANGS); + npcData.entityList.put("EXPERIENCE_BOTTLE", EntityType.EXPERIENCE_BOTTLE); + npcData.entityList.put("EXPERIENCE_ORB", EntityType.EXPERIENCE_ORB); + npcData.entityList.put("EYE_OF_ENDER", EntityType.EYE_OF_ENDER); + npcData.entityList.put("FALLING_BLOCK", EntityType.FALLING_BLOCK); + npcData.entityList.put("FIREBALL", EntityType.FIREBALL); + npcData.entityList.put("FIREWORK_ROCKET", EntityType.FIREWORK_ROCKET); + npcData.entityList.put("FISHING_BOBBER", EntityType.FISHING_BOBBER); + npcData.entityList.put("FOX", EntityType.FOX); + npcData.entityList.put("FROG", EntityType.FROG); + npcData.entityList.put("FURNACE_MINECART", EntityType.FURNACE_MINECART); + npcData.entityList.put("GHAST", EntityType.GHAST); + npcData.entityList.put("GIANT", EntityType.GIANT); + npcData.entityList.put("GLOW_ITEM_FRAME", EntityType.GLOW_ITEM_FRAME); + npcData.entityList.put("GLOW_SQUID", EntityType.GLOW_SQUID); + npcData.entityList.put("GOAT", EntityType.GOAT); + npcData.entityList.put("GUARDIAN", EntityType.GUARDIAN); + npcData.entityList.put("HOGLIN", EntityType.HOGLIN); + npcData.entityList.put("HOPPER_MINECART", EntityType.HOPPER_MINECART); + npcData.entityList.put("HORSE", EntityType.HORSE); + npcData.entityList.put("HUSK", EntityType.HUSK); + npcData.entityList.put("ILLUSIONER", EntityType.ILLUSIONER); + npcData.entityList.put("INTERACTION", EntityType.INTERACTION); + npcData.entityList.put("IRON_GOLEM", EntityType.IRON_GOLEM); + npcData.entityList.put("ITEM", EntityType.ITEM); + npcData.entityList.put("ITEM_DISPLAY", EntityType.ITEM_DISPLAY); + npcData.entityList.put("ITEM_FRAME", EntityType.ITEM_FRAME); + npcData.entityList.put("LEASH_KNOT", EntityType.LEASH_KNOT); + npcData.entityList.put("LIGHTNING_BOLT", EntityType.LIGHTNING_BOLT); + npcData.entityList.put("LLAMA", EntityType.LLAMA); + npcData.entityList.put("LLAMA_SPIT", EntityType.LLAMA_SPIT); + npcData.entityList.put("MAGMA_CUBE", EntityType.MAGMA_CUBE); + npcData.entityList.put("MARKER", EntityType.MARKER); + npcData.entityList.put("MINECART", EntityType.MINECART); + npcData.entityList.put("MOOSHROOM", EntityType.MOOSHROOM); + npcData.entityList.put("MULE", EntityType.MULE); + npcData.entityList.put("OCELOT", EntityType.OCELOT); + npcData.entityList.put("PAINTING", EntityType.PAINTING); + npcData.entityList.put("PANDA", EntityType.PANDA); + npcData.entityList.put("PARROT", EntityType.PARROT); + npcData.entityList.put("PHANTOM", EntityType.PHANTOM); + npcData.entityList.put("PIG", EntityType.PIG); + npcData.entityList.put("PIGLIN", EntityType.PIGLIN); + npcData.entityList.put("PIGLIN_BRUTE", EntityType.PIGLIN_BRUTE); + npcData.entityList.put("PILLAGER", EntityType.PILLAGER); + npcData.entityList.put("PLAYER", EntityType.PLAYER); + npcData.entityList.put("POLAR_BEAR", EntityType.POLAR_BEAR); + npcData.entityList.put("POTION", EntityType.POTION); + npcData.entityList.put("PUFFERFISH", EntityType.PUFFERFISH); + npcData.entityList.put("RABBIT", EntityType.RABBIT); + npcData.entityList.put("RAVAGER", EntityType.RAVAGER); + npcData.entityList.put("SALMON", EntityType.SALMON); + npcData.entityList.put("SHEEP", EntityType.SHEEP); + npcData.entityList.put("SHULKER", EntityType.SHULKER); + npcData.entityList.put("SHULKER_BULLET", EntityType.SHULKER_BULLET); + npcData.entityList.put("SILVERFISH", EntityType.SILVERFISH); + npcData.entityList.put("SKELETON", EntityType.SKELETON); + npcData.entityList.put("SKELETON_HORSE", EntityType.SKELETON_HORSE); + npcData.entityList.put("SLIME", EntityType.SLIME); + npcData.entityList.put("SMALL_FIREBALL", EntityType.SMALL_FIREBALL); + npcData.entityList.put("SNIFFER", EntityType.SNIFFER); + npcData.entityList.put("SNOW_GOLEM", EntityType.SNOW_GOLEM); + npcData.entityList.put("SNOWBALL", EntityType.SNOWBALL); + npcData.entityList.put("SPAWNER_MINECART", EntityType.SPAWNER_MINECART); + npcData.entityList.put("SPECTRAL_ARROW", EntityType.SPECTRAL_ARROW); + npcData.entityList.put("SPIDER", EntityType.SPIDER); + npcData.entityList.put("SQUID", EntityType.SQUID); + npcData.entityList.put("STRAY", EntityType.STRAY); + npcData.entityList.put("STRIDER", EntityType.STRIDER); + npcData.entityList.put("TADPOLE", EntityType.TADPOLE); + npcData.entityList.put("TEXT_DISPLAY", EntityType.TEXT_DISPLAY); + npcData.entityList.put("TNT", EntityType.TNT); + npcData.entityList.put("TNT_MINECART", EntityType.TNT_MINECART); + npcData.entityList.put("TRADER_LLAMA", EntityType.TRADER_LLAMA); + npcData.entityList.put("TRIDENT", EntityType.TRIDENT); + npcData.entityList.put("TROPICAL_FISH", EntityType.TROPICAL_FISH); + npcData.entityList.put("TURTLE", EntityType.TURTLE); + npcData.entityList.put("VEX", EntityType.VEX); + npcData.entityList.put("VILLAGER", EntityType.VILLAGER); + npcData.entityList.put("VINDICATOR", EntityType.VINDICATOR); + npcData.entityList.put("WANDERING_TRADER", EntityType.WANDERING_TRADER); + npcData.entityList.put("WARDEN", EntityType.WARDEN); + npcData.entityList.put("WIND_CHARGE", EntityType.WIND_CHARGE); + npcData.entityList.put("WITCH", EntityType.WITCH); + npcData.entityList.put("WITHER", EntityType.WITHER); + npcData.entityList.put("WITHER_SKELETON", EntityType.WITHER_SKELETON); + npcData.entityList.put("WITHER_SKULL", EntityType.WITHER_SKULL); + npcData.entityList.put("WOLF", EntityType.WOLF); + npcData.entityList.put("ZOGLIN", EntityType.ZOGLIN); + npcData.entityList.put("ZOMBIE", EntityType.ZOMBIE); + npcData.entityList.put("ZOMBIE_HORSE", EntityType.ZOMBIE_HORSE); + npcData.entityList.put("ZOMBIE_VILLAGER", EntityType.ZOMBIE_VILLAGER); + npcData.entityList.put("ZOMBIFIED_PIGLIN", EntityType.ZOMBIFIED_PIGLIN); + } + + } + + public void modEntity(String entType) { + this.npcData.playerEntity.put("Entity", entType); + } + /** * Creates default taterzen attributes. @@ -200,30 +355,6 @@ public static AttributeSupplier.Builder createTaterzenAttributes() { .add(Attributes.FOLLOW_RANGE, 35.0D); } - /** - * Creates a fake player for this NPC - * in order to be able to use the - * player synched data. - */ - public void constructFakePlayer() { - this.fakePlayer = new ServerPlayer(this.getServer(), (ServerLevel) this.level(), this.gameProfile, new ClientInformation( - "en_US", - 0, - ChatVisiblity.FULL, - true, - 0x7f, - HumanoidArm.RIGHT, - false, - false - )); - this.fakePlayer.getEntityData().set(getPLAYER_MODE_CUSTOMISATION(), (byte) 0x7f); - this.fakePlayer.setPos(this.getX(), this.getY(), this.getZ()); - this.fakePlayer.setXRot(this.getXRot()); - this.fakePlayer.setYRot(this.getYRot()); - this.fakePlayer.setYHeadRot(this.yHeadRot); - this.fakePlayer.setCustomName(this.getDisplayName()); - } - /** * Adds sounds to the list of ambient sounds of a Taterzen. * @@ -359,7 +490,7 @@ public void setPermissionLevel(int newPermissionLevel) { } /** - * Sets {@link org.samo_lego.taterzens.npc.NPCData.Movement movement type} + * Sets {@link NPCData.Movement movement type} * and initialises the goals. * * @param movement movement type @@ -426,36 +557,6 @@ public void addPathTarget(BlockPos blockPos) { this.restrictTo(this.npcData.pathTargets.get(0), 1); } - @Override - public SynchedEntityData getEntityData() { - if (this.fakePlayer == null) { - // Fixes gravity changer incompatibility - this.constructFakePlayer(); - } - return this.fakePlayer.getEntityData(); - } - - /** - * Handles name visibility on sneaking - * - * @param sneaking whether npc's name should look like on sneaking. - */ - @Override - public void setShiftKeyDown(boolean sneaking) { - this.fakePlayer.setShiftKeyDown(sneaking); - super.setShiftKeyDown(sneaking); - } - - /** - * Sets the npc pose. - * - * @param pose entity pose. - */ - @Override - public void setPose(Pose pose) { - this.fakePlayer.setPose(pose); - super.setPose(pose); - } /** * Removes node from path targets. @@ -484,7 +585,7 @@ public void clearPathTargets() { } /** - * Ticks the movement depending on {@link org.samo_lego.taterzens.npc.NPCData.Movement} type + * Ticks the movement depending on {@link NPCData.Movement} type */ @Override public void aiStep() { @@ -555,14 +656,14 @@ public void aiStep() { public void tick() { super.tick(); - AABB box = this.getBoundingBox().inflate(4.0D); + AABB box = this.getBoundingBox().inflate(config.messages.speakDistance); List players = this.level().getEntitiesOfClass(ServerPlayer.class, box); if (!this.npcData.messages.isEmpty()) { for (ServerPlayer player : players) { // Filter them here (not use a predicate above) // as we need the original list below - if (((ITaterzenEditor) player).getEditorMode() == ITaterzenEditor.EditorMode.MESSAGES || this.distanceTo(player) > config.messages.speakDistance) { + if (((ITaterzenEditor) player).getEditorMode() == ITaterzenEditor.EditorMode.MESSAGES) { continue; } @@ -599,24 +700,6 @@ public void tick() { } } - @Override - public Packet getAddEntityPacket() { - return new ClientboundAddEntityPacket( - this.getId(), - this.getUUID(), - this.getX(), - this.getY(), - this.getZ(), - this.getXRot(), - this.getYRot(), - EntityType.PLAYER, - 0, - this.getDeltaMovement(), - this.getYHeadRot() - ); - - } - public GameProfile getGameProfile() { return this.gameProfile; } @@ -652,21 +735,24 @@ public void setCustomName(Component name) { this.gameProfile = new GameProfile(this.getUUID(), profileName); if (skin != null) { this.setSkinFromTag(skin); - this.sendProfileUpdates(); + this.broadcastProfileUpdates(); } } /** * Updates Taterzen's {@link GameProfile} for others. */ - public void sendProfileUpdates() { + public void broadcastProfileUpdates() { if (this.level().isClientSide()) return; ServerChunkCache manager = (ServerChunkCache) this.level().getChunkSource(); ChunkMap storage = manager.chunkMap; AEntityTrackerEntry trackerEntry = ((AChunkMap) storage).getEntityMap().get(this.getId()); if (trackerEntry != null) { - trackerEntry.getSeenBy().forEach(tracking -> trackerEntry.getPlayer().addPairing(tracking.getPlayer())); + trackerEntry.getSeenBy().forEach(tracking -> { + trackerEntry.getPlayer().removePairing(tracking.getPlayer()); + trackerEntry.getPlayer().addPairing(tracking.getPlayer()); + }); } } @@ -684,7 +770,7 @@ public void applySkin(GameProfile texturesProfile) { setSkinFromTag(writeSkinToTag(texturesProfile)); // Sending updates - this.sendProfileUpdates(); + this.broadcastProfileUpdates(); } /** @@ -800,7 +886,7 @@ public void readAdditionalSaveData(CompoundTag tag) { ListTag pathTargets = (ListTag) npcTag.get("PathTargets"); if (pathTargets != null) { - if (pathTargets.size() > 0) { + if (!pathTargets.isEmpty()) { pathTargets.forEach(posTag -> { if (posTag instanceof CompoundTag pos) { BlockPos target = new BlockPos(pos.getInt("x"), pos.getInt("y"), pos.getInt("z")); @@ -813,7 +899,7 @@ public void readAdditionalSaveData(CompoundTag tag) { this.npcData.currentMoveTarget = npcTag.getInt("CurrentMoveTarget"); ListTag messages = (ListTag) npcTag.get("Messages"); - if (messages != null && messages.size() > 0) { + if (messages != null && !messages.isEmpty()) { messages.forEach(msgTag -> { CompoundTag msgCompound = (CompoundTag) msgTag; this.addMessage(TextUtil.fromNbtElement(msgCompound.get("Message")), msgCompound.getInt("Delay")); @@ -842,11 +928,11 @@ public void readAdditionalSaveData(CompoundTag tag) { // Profession initialising ListTag professions = (ListTag) npcTag.get("Professions"); - if (professions != null && professions.size() > 0) { + if (professions != null && !professions.isEmpty()) { professions.forEach(professionTag -> { CompoundTag professionCompound = (CompoundTag) professionTag; - ResourceLocation professionId = new ResourceLocation(professionCompound.getString("ProfessionType")); + ResourceLocation professionId = ResourceLocation.parse(professionCompound.getString("ProfessionType")); if (PROFESSION_TYPES.containsKey(professionId)) { TaterzenProfession profession = PROFESSION_TYPES.get(professionId).apply(this); this.addProfession(professionId, profession); @@ -893,6 +979,30 @@ public void readAdditionalSaveData(CompoundTag tag) { this.setAllowSwimming(npcTag.getBoolean("AllowSwimming")); // -------------------------------------------------------------- + + // This magic is where we check on loading in whether the NPC has a different TYPE to what is expected + // Normally, it will default to PLAYER, but we want the TYPE changes to be persistent + // The logger is pushing details to the minecraft log so you can see it actually parsing things + + getLogger("Taterzens").info("[Taterzens]: Out of interest, the Tag Entity is {}.", npcTag.get("Entity")); + + if (npcTag.contains("Entity")) { + // Update it to the current settting + if (npcTag.get("Entity") == null) { + getLogger("Taterzens").error("[Taterzens]: In the SaveDataread."); + + npcTag.putString("Entity", "PLAYER"); + npcData.playerEntity.put("Entity", "PLAYER"); + } else { + getLogger("Taterzens").info("[Taterzens]: We have a valid Entity setting and are putting it in the Tag"); + // + // It's actually this we need to update since we have it stored, and the playerEntity hashmap is what we're using + npcData.playerEntity.put("Entity", npcTag.getString("Entity")); + // And we need to override the other setting + npcTag.putString("Entity", npcTag.getString("Entity")); + } + } + this.setMinCommandInteractionTime(npcTag.getLong("MinCommandInteractionTime")); } @@ -922,7 +1032,7 @@ public void addAdditionalSaveData(CompoundTag tag) { npcTag.put("Tags", tags); // Skin layers - npcTag.putByte("SkinLayers", this.fakePlayer.getEntityData().get(getPLAYER_MODE_CUSTOMISATION())); + npcTag.putByte("SkinLayers", this.npcData.skinLayers); // Sounds ListTag ambientSounds = new ListTag(); @@ -1000,6 +1110,15 @@ public void addAdditionalSaveData(CompoundTag tag) { npcTag.putLong("MinCommandInteractionTime", this.npcData.minCommandInteractionTime); + + getLogger("Taterzens").info("[Taterzens]: The Game is paused or saving. We're setting NPC entity to {}", npcData.playerEntity.get("Entity")); + + // We take whatever the npc has been changed to and shove it in the tag. + // Only end up in here on pausing or saving to quit + if (npcData.playerEntity.get("Entity") != null) { + npcTag.putString("Entity", npcData.playerEntity.get("Entity")); + } + tag.put("TaterzenNPCTag", npcTag); } @@ -1083,8 +1202,9 @@ public InteractionResult mobInteract(Player player, InteractionHand hand) { // As weird as it sounds, this gets triggered twice, first time with the item stack player is holding // then with "air" if fake type is player / armor stand - if (lastAction - ipl.getLastInteractionTime() < 50) + if (lastAction - ipl.getLastInteractionTime() < 50) { return InteractionResult.FAIL; + } ipl.setLastInteraction(lastAction); @@ -1098,21 +1218,18 @@ public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack stack = player.getItemInHand(hand).copy(); if (stack.isEmpty() && player.isShiftKeyDown()) { - this.dropCustomDeathLoot(this.damageSources().playerAttack(player), 1, this.isEquipmentDropsAllowed()); - for (EquipmentSlot slot : EquipmentSlot.values()) { - this.fakePlayer.setItemSlot(slot, ItemStack.EMPTY); - } + // TODO fix the Custom DeathLoot drops. They've changed with 1.21. + // this.dropCustomDeathLoot(this.damageSources().playerAttack(player), 1, this.isEquipmentDropsAllowed()); } else if (player.isShiftKeyDown()) { this.setItemSlot(EquipmentSlot.MAINHAND, stack); - this.fakePlayer.setItemSlot(EquipmentSlot.MAINHAND, stack); } else { EquipmentSlot slot = getEquipmentSlotForItem(stack); this.setItemSlotAndDropWhenKilled(slot, stack); - this.fakePlayer.setItemSlot(slot, stack); } // Updating behaviour (if npc had a sword and now has a bow, it won't // be able to attack otherwise.) this.setBehaviour(this.npcData.behaviour); + return InteractionResult.PASS; } else if ( player.getItemInHand(hand).getItem().equals(Items.POTATO) && @@ -1168,7 +1285,8 @@ public void setMinCommandInteractionTime(long time) { this.npcData.minCommandInteractionTime = time; } - +/* + // TODO: Fix the dropCustomDeathLoot code to match 1.21. Mainly it needs Serverlevel to be provided. @Override protected void dropCustomDeathLoot(DamageSource source, int lootingMultiplier, boolean allowDrops) { // Additional drop check @@ -1180,7 +1298,7 @@ protected void dropCustomDeathLoot(DamageSource source, int lootingMultiplier, b } } } - +*/ @Override protected boolean shouldDropLoot() { return this.isEquipmentDropsAllowed(); @@ -1327,11 +1445,13 @@ protected boolean isSunBurnTick() { return false; } + /* + // TODO: Fix the isLeashed code in accordance with the 1.21 changes. @Override public boolean canBeLeashed(Player player) { return !this.isLeashed() && this.isLeashable(); } - + */ /** * Gets whether this NPC is leashable. * @@ -1387,7 +1507,7 @@ public void die(DamageSource source) { } @Override - public void remove(Entity.RemovalReason reason) { + public void remove(RemovalReason reason) { super.remove(reason); TATERZEN_NPCS.remove(this.getUUID()); @@ -1477,16 +1597,18 @@ public boolean canFireProjectileWeapon(ProjectileWeaponItem weapon) { @Override public void setChargingCrossbow(boolean charging) { } + /* + + // TODO: Fix the shootProjectile code to match the 1.21 implementation @Override public void shootCrossbowProjectile(LivingEntity target, ItemStack crossbow, Projectile projectile, float multiShotSpray) { var weaponHand = ProjectileUtil.getWeaponHoldingHand(this, Items.CROSSBOW); - this.fakePlayer.startUsingItem(weaponHand); this.startUsingItem(weaponHand); // Crossbow attack this.shootProjectile(target, projectile, multiShotSpray); } - + */ @Override public void onCrossbowAttackPerformed() { } @@ -1505,10 +1627,9 @@ public void performRangedAttack(LivingEntity target, float pullProgress) { if (arrowType.isEmpty()) arrowType = this.getProjectile(this.getItemInHand(ProjectileUtil.getWeaponHoldingHand(this, Items.CROSSBOW))); - AbstractArrow projectile = ProjectileUtil.getMobArrow(this, arrowType.copy(), pullProgress); + AbstractArrow projectile = ProjectileUtil.getMobArrow(this, arrowType.copy(), pullProgress, null); //bow.use(this.level, this.fakePlayer, weaponHand); - this.fakePlayer.startUsingItem(weaponHand); this.startUsingItem(weaponHand); this.shootProjectile(target, projectile, 0.0F); } @@ -1518,9 +1639,12 @@ private void shootProjectile(LivingEntity target, Projectile projectile, float m double y = target.getY(0.3333333333333333D) - projectile.getY(); double deltaZ = target.getZ() - this.getZ(); double planeDistance = Mth.sqrt((float) (deltaX * deltaX + deltaZ * deltaZ)); - Vector3f launchVelocity = this.getProjectileShotVector(this, new Vec3(deltaX, y + planeDistance * 0.2D, deltaZ), multishotSpray); - projectile.shoot(launchVelocity.x(), launchVelocity.y(), launchVelocity.z(), 1.6F, 0); + // TODO: Fix this projectile related code to meet the 1.21 implementation + + // Vector3f launchVelocity = this.getProjectileShotVector(this, new Vec3(deltaX, y + planeDistance * 0.2D, deltaZ), multishotSpray); + + // projectile.shoot(launchVelocity.x(), launchVelocity.y(), launchVelocity.z(), 1.6F, 0); this.playSound(SoundEvents.ARROW_SHOOT, 1.0F, 0.125F); this.level().addFreshEntity(projectile); @@ -1541,7 +1665,7 @@ protected SoundEvent getAmbientSound() { return null; int rnd = this.random.nextInt(this.npcData.ambientSounds.size()); - ResourceLocation sound = new ResourceLocation(this.npcData.ambientSounds.get(rnd)); + ResourceLocation sound = ResourceLocation.parse(this.npcData.ambientSounds.get(rnd)); return BuiltInRegistries.SOUND_EVENT.get(sound); } @@ -1560,7 +1684,7 @@ protected SoundEvent getHurtSound(DamageSource source) { return null; int rnd = this.random.nextInt(this.npcData.hurtSounds.size()); - ResourceLocation sound = new ResourceLocation(this.npcData.hurtSounds.get(rnd)); + ResourceLocation sound = ResourceLocation.parse(this.npcData.hurtSounds.get(rnd)); return BuiltInRegistries.SOUND_EVENT.get(sound); } @@ -1579,7 +1703,7 @@ protected SoundEvent getDeathSound() { return null; int rnd = this.random.nextInt(this.npcData.deathSounds.size()); - ResourceLocation sound = new ResourceLocation(this.npcData.deathSounds.get(rnd)); + ResourceLocation sound = ResourceLocation.parse(this.npcData.deathSounds.get(rnd)); return BuiltInRegistries.SOUND_EVENT.get(sound); } @@ -1602,9 +1726,6 @@ protected Component getTypeName() { return Component.literal("-" + config.defaults.name + "-"); } - public ServerPlayer getFakePlayer() { - return this.fakePlayer; - } /** * Toggles whether Taterzen will drop its equipment. @@ -1626,7 +1747,7 @@ public boolean isEquipmentDropsAllowed() { /** * Adds {@link TaterzenProfession} to Taterzen. - * Profession must be registered with {@link org.samo_lego.taterzens.api.TaterzensAPI#registerProfession(ResourceLocation, Function)}. + * Profession must be registered with {@link TaterzensAPI#registerProfession(ResourceLocation, Function)}. * * @param professionId ResourceLocation of the profession */ @@ -1717,8 +1838,9 @@ public boolean interact(BlockPos pos) { if (this.position().distanceTo(Vec3.atCenterOf(pos)) < 4.0D && !this.level().isClientSide()) { this.lookAt(pos); this.swing(MAIN_HAND); - this.level().getBlockState(pos).use(this.level(), this.fakePlayer, MAIN_HAND, new BlockHitResult(Vec3.atCenterOf(pos), Direction.DOWN, pos, false)); - this.getMainHandItem().use(this.level(), this.fakePlayer, MAIN_HAND); + // todo + //this.level().getBlockState(pos).use(this.level(), this, MAIN_HAND, new BlockHitResult(Vec3.atCenterOf(pos), Direction.DOWN, pos, false)); + //this.getMainHandItem().use(this.level(), this, MAIN_HAND); return true; } return false; @@ -1813,8 +1935,8 @@ public void setAllowSounds(boolean allowSounds) { * * @param skinLayers byte of skin layers, see wiki.wg for more info. */ - public void setSkinLayers(Byte skinLayers) { - this.fakePlayer.getEntityData().set(getPLAYER_MODE_CUSTOMISATION(), skinLayers); + public void setSkinLayers(byte skinLayers) { + this.npcData.skinLayers = skinLayers; } @@ -1945,7 +2067,8 @@ public void setAllowSwimming(boolean allowSwimming) { this.setTag("AllowSwimming", allowSwimming); } - private void setTag(String name, boolean value) { + // Change this to public, since we want to use it elsewhere + public void setTag(String name, boolean value) { this.npcData.booleanTags.put(name, value); } @@ -1958,4 +2081,45 @@ private boolean getTag(String name, boolean defaultValue) { return this.npcData.booleanTags.get(name); return defaultValue; } + + @Override + public EntityType getPolymerEntityType(ServerPlayer player) { + // All that other work for such a pretty little line of code + return npcData.entityList.get(npcData.playerEntity.get("Entity")); + } + + @Override + public void modifyRawTrackedData(List> data, ServerPlayer player, boolean initial) { + // Fake selection glow + ((ITaterzenEditor) player).getSelectedNpc().ifPresent(npc -> { + if (this == npc && config.glowSelectedNpc) { + + // TODO: Fix this particular line. There's issues with what's being returned + + //data.removeIf(value -> value.id() == Entity.DATA_SHARED_FLAGS_ID.getId()); + + // Modify Taterzen to have fake glowing effect for the player + byte flags = this.entityData.get(Entity.DATA_SHARED_FLAGS_ID); + flags = (byte) (flags | 1 << Entity.FLAG_GLOWING); + + SynchedEntityData.DataValue glowingTag = SynchedEntityData.DataValue.create(Entity.DATA_SHARED_FLAGS_ID, flags); + data.add(glowingTag); + } + }); + + // Skin layer settings + + // TODO: Fix this for the same reasons as the above commented out line. + // data.removeIf(value -> value.id() == getPLAYER_MODE_CUSTOMISATION().getId()); + + SynchedEntityData.DataValue skinLayerTag = SynchedEntityData.DataValue.create(getPLAYER_MODE_CUSTOMISATION(), this.npcData.skinLayers); + data.add(skinLayerTag); + } + + @Override + public void onBeforeSpawnPacket(ServerPlayer player, Consumer> packetConsumer) { + var packet = PolymerEntityUtils.createMutablePlayerListPacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LISTED)); + packet.entries().add(new ClientboundPlayerInfoUpdatePacket.Entry(this.uuid, this.gameProfile, false, 0, GameType.SURVIVAL, null, null)); + packetConsumer.accept(packet); + } } diff --git a/common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/DirectPathGoal.java b/src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/DirectPathGoal.java similarity index 83% rename from common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/DirectPathGoal.java rename to src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/DirectPathGoal.java index c4687a3df..563978994 100644 --- a/common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/DirectPathGoal.java +++ b/src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/DirectPathGoal.java @@ -1,11 +1,12 @@ -package org.samo_lego.taterzens.npc.ai.goal; +package org.samo_lego.taterzens.common.npc.ai.goal; import net.minecraft.world.entity.PathfinderMob; import net.minecraft.world.entity.ai.goal.MoveTowardsRestrictionGoal; +import org.samo_lego.taterzens.common.npc.NPCData; /** - * Goal used in {@link org.samo_lego.taterzens.npc.NPCData.Movement FORCED_PATH} movement. + * Goal used in {@link NPCData.Movement FORCED_PATH} movement. */ public class DirectPathGoal extends MoveTowardsRestrictionGoal { diff --git a/common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/LazyPathGoal.java b/src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/LazyPathGoal.java similarity index 68% rename from common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/LazyPathGoal.java rename to src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/LazyPathGoal.java index 52102cf4c..5b8b6d5d2 100644 --- a/common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/LazyPathGoal.java +++ b/src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/LazyPathGoal.java @@ -1,11 +1,11 @@ -package org.samo_lego.taterzens.npc.ai.goal; +package org.samo_lego.taterzens.common.npc.ai.goal; import net.minecraft.world.entity.PathfinderMob; -import net.minecraft.world.entity.ai.goal.MoveToBlockGoal; +import org.samo_lego.taterzens.common.npc.NPCData; /** - * Goal used in {@link org.samo_lego.taterzens.npc.NPCData.Movement#PATH} movement. + * Goal used in {@link NPCData.Movement#PATH} movement. */ public class LazyPathGoal extends DirectPathGoal { @@ -27,6 +27,6 @@ public boolean canUse() { return true; } private int nextStartTick(PathfinderMob mob) { - return MoveToBlockGoal.reducedTickDelay(200 + mob.getRandom().nextInt(200)); + return reducedTickDelay(200 + mob.getRandom().nextInt(200)); } } diff --git a/common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/ReachMeleeAttackGoal.java b/src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/ReachMeleeAttackGoal.java similarity index 84% rename from common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/ReachMeleeAttackGoal.java rename to src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/ReachMeleeAttackGoal.java index 94aebe600..4153fd403 100644 --- a/common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/ReachMeleeAttackGoal.java +++ b/src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/ReachMeleeAttackGoal.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.npc.ai.goal; +package org.samo_lego.taterzens.common.npc.ai.goal; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.PathfinderMob; @@ -22,9 +22,4 @@ public boolean canContinueToUse() { } return !(livingEntity instanceof Player) || (!livingEntity.isSpectator() && !((Player) livingEntity).isCreative()); } - - @Override - protected double getAttackReachSqr(LivingEntity entity) { - return 12.25D; - } } diff --git a/common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/TeamRevengeGoal.java b/src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/TeamRevengeGoal.java similarity index 94% rename from common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/TeamRevengeGoal.java rename to src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/TeamRevengeGoal.java index 0b5d2b54a..f0a3acd8c 100644 --- a/common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/TeamRevengeGoal.java +++ b/src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/TeamRevengeGoal.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.npc.ai.goal; +package org.samo_lego.taterzens.common.npc.ai.goal; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.PathfinderMob; diff --git a/common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/TrackEntityGoal.java b/src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/TrackEntityGoal.java similarity index 98% rename from common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/TrackEntityGoal.java rename to src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/TrackEntityGoal.java index ae2677919..c728dbe24 100644 --- a/common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/TrackEntityGoal.java +++ b/src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/TrackEntityGoal.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.npc.ai.goal; +package org.samo_lego.taterzens.common.npc.ai.goal; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; diff --git a/common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/TrackUuidGoal.java b/src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/TrackUuidGoal.java similarity index 97% rename from common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/TrackUuidGoal.java rename to src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/TrackUuidGoal.java index d00bb7f7a..f599cbf92 100644 --- a/common/src/main/java/org/samo_lego/taterzens/npc/ai/goal/TrackUuidGoal.java +++ b/src/main/java/org/samo_lego/taterzens/common/npc/ai/goal/TrackUuidGoal.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.npc.ai.goal; +package org.samo_lego.taterzens.common.npc.ai.goal; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.PathfinderMob; diff --git a/common/src/main/java/org/samo_lego/taterzens/npc/commands/AbstractTaterzenCommand.java b/src/main/java/org/samo_lego/taterzens/common/npc/commands/AbstractTaterzenCommand.java similarity index 87% rename from common/src/main/java/org/samo_lego/taterzens/npc/commands/AbstractTaterzenCommand.java rename to src/main/java/org/samo_lego/taterzens/common/npc/commands/AbstractTaterzenCommand.java index a7f9d4766..6c4b8a5ba 100644 --- a/common/src/main/java/org/samo_lego/taterzens/npc/commands/AbstractTaterzenCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/npc/commands/AbstractTaterzenCommand.java @@ -1,8 +1,8 @@ -package org.samo_lego.taterzens.npc.commands; +package org.samo_lego.taterzens.common.npc.commands; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.player.Player; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; public abstract class AbstractTaterzenCommand { public static final String CLICKER_PLACEHOLDER = "--clicker--"; diff --git a/common/src/main/java/org/samo_lego/taterzens/npc/commands/BungeeCommand.java b/src/main/java/org/samo_lego/taterzens/common/npc/commands/BungeeCommand.java similarity index 84% rename from common/src/main/java/org/samo_lego/taterzens/npc/commands/BungeeCommand.java rename to src/main/java/org/samo_lego/taterzens/common/npc/commands/BungeeCommand.java index d0e0fd201..976000d4c 100644 --- a/common/src/main/java/org/samo_lego/taterzens/npc/commands/BungeeCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/npc/commands/BungeeCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.npc.commands; +package org.samo_lego.taterzens.common.npc.commands; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; @@ -10,14 +10,19 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.ServerGamePacketListenerImpl; import net.minecraft.world.entity.player.Player; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.util.ArrayList; import java.util.Locale; -import static org.samo_lego.taterzens.Taterzens.config; +import static org.samo_lego.taterzens.common.Taterzens.config; +/* + Query as to viability of Bungee Server support. Is this a function that still needs to be implemented in the mod? + If not, we can remove Bungee Command and Server code and solve some 1.21 implemntation issues quickly. + +*/ public class BungeeCommand extends AbstractTaterzenCommand { /** * Contains all available proxy servers. @@ -27,7 +32,7 @@ public class BungeeCommand extends AbstractTaterzenCommand { /** * Identifier of the proxy message channel. */ - public static final ResourceLocation BUNGEE_CHANNEL = new ResourceLocation("bungeecord", "main"); + public static final ResourceLocation BUNGEE_CHANNEL = ResourceLocation.fromNamespaceAndPath("bungeecord", "main"); private String argument; private BungeeMessage proxyMessage; private String playername; @@ -67,8 +72,10 @@ public static void sendProxyPacket(ServerGamePacketListenerImpl connection, byte buf.writeResourceLocation(BUNGEE_CHANNEL); buf.writeBytes(data); - ClientboundCustomPayloadPacket packet = new ClientboundCustomPayloadPacket(buf); - connection.send(packet); + // TODO: If we're keeping Bungee support, fix this + + // ClientboundCustomPayloadPacket packet = new ClientboundCustomPayloadPacket(buf); + // connection.send(packet); } @Override @@ -105,8 +112,10 @@ public void execute(TaterzenNPC npc, Player player) { buf.writeResourceLocation(BUNGEE_CHANNEL); buf.writeBytes(out.toByteArray()); - ClientboundCustomPayloadPacket packet = new ClientboundCustomPayloadPacket(buf); - ((ServerPlayer) player).connection.send(packet); + // TODO: If we're keeping Bungee support, fix this + + //ClientboundCustomPayloadPacket packet = new ClientboundCustomPayloadPacket(buf); + //((ServerPlayer) player).connection.send(packet); } diff --git a/common/src/main/java/org/samo_lego/taterzens/npc/commands/CommandGroups.java b/src/main/java/org/samo_lego/taterzens/common/npc/commands/CommandGroups.java similarity index 97% rename from common/src/main/java/org/samo_lego/taterzens/npc/commands/CommandGroups.java rename to src/main/java/org/samo_lego/taterzens/common/npc/commands/CommandGroups.java index fbc25938f..b0e74da94 100644 --- a/common/src/main/java/org/samo_lego/taterzens/npc/commands/CommandGroups.java +++ b/src/main/java/org/samo_lego/taterzens/common/npc/commands/CommandGroups.java @@ -1,10 +1,10 @@ -package org.samo_lego.taterzens.npc.commands; +package org.samo_lego.taterzens.common.npc.commands; import com.google.common.collect.ImmutableList; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.server.level.ServerPlayer; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.util.ArrayList; diff --git a/common/src/main/java/org/samo_lego/taterzens/npc/commands/MinecraftCommand.java b/src/main/java/org/samo_lego/taterzens/common/npc/commands/MinecraftCommand.java similarity index 90% rename from common/src/main/java/org/samo_lego/taterzens/npc/commands/MinecraftCommand.java rename to src/main/java/org/samo_lego/taterzens/common/npc/commands/MinecraftCommand.java index 6141067d5..badf10a60 100644 --- a/common/src/main/java/org/samo_lego/taterzens/npc/commands/MinecraftCommand.java +++ b/src/main/java/org/samo_lego/taterzens/common/npc/commands/MinecraftCommand.java @@ -1,8 +1,8 @@ -package org.samo_lego.taterzens.npc.commands; +package org.samo_lego.taterzens.common.npc.commands; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.player.Player; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; public class MinecraftCommand extends AbstractTaterzenCommand { private String command; diff --git a/common/src/main/java/org/samo_lego/taterzens/platform/Platform.java b/src/main/java/org/samo_lego/taterzens/common/platform/Platform.java similarity index 62% rename from common/src/main/java/org/samo_lego/taterzens/platform/Platform.java rename to src/main/java/org/samo_lego/taterzens/common/platform/Platform.java index 14d013640..3ded14fe6 100644 --- a/common/src/main/java/org/samo_lego/taterzens/platform/Platform.java +++ b/src/main/java/org/samo_lego/taterzens/common/platform/Platform.java @@ -1,35 +1,35 @@ -package org.samo_lego.taterzens.platform; +package org.samo_lego.taterzens.common.platform; import net.minecraft.commands.CommandSourceStack; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.nio.file.Path; /** * Base class for platform implementations. */ -public abstract class Platform { +public interface Platform { /** * Gets the path to the directory where the config files are stored. * @return the path to the directory where the config files are stored. */ - public abstract Path getConfigDirPath(); + Path getConfigDirPath(); /** * Checks whether certain mod is loaded. * @param modId the mod id. * @return true if the mod is loaded, false otherwise. */ - public abstract boolean isModLoaded(String modId); + boolean isModLoaded(String modId); /** * Gets size of item registry. * @return size of item registry. */ - public abstract int getItemRegistrySize(); + int getItemRegistrySize(); /** * Checks for permission of provided command source. @@ -38,18 +38,17 @@ public abstract class Platform { * @param fallbackLevel the fallback level to use if the permission node is not set. * @return true if the command source has the permission node, false otherwise. */ - public abstract boolean checkPermission(CommandSourceStack source, String permissionNode, int fallbackLevel); + boolean checkPermission(CommandSourceStack source, String permissionNode, int fallbackLevel); /** * Registers the taterzen entity type. */ - public abstract void registerTaterzenType(); + void registerTaterzenType(); - public void openEditorGui(ServerPlayer player) { - } + void openEditorGui(ServerPlayer player); - public abstract void disguiseAs(TaterzenNPC taterzen, Entity entity); + void disguiseAs(TaterzenNPC taterzen, Entity entity); - public abstract void clearDisguise(TaterzenNPC taterzen); + void clearDisguise(TaterzenNPC taterzen); } diff --git a/common/src/main/java/org/samo_lego/taterzens/storage/TaterConfig.java b/src/main/java/org/samo_lego/taterzens/common/storage/TaterConfig.java similarity index 96% rename from common/src/main/java/org/samo_lego/taterzens/storage/TaterConfig.java rename to src/main/java/org/samo_lego/taterzens/common/storage/TaterConfig.java index e0ef10f4b..cbb1a6ec7 100644 --- a/common/src/main/java/org/samo_lego/taterzens/storage/TaterConfig.java +++ b/src/main/java/org/samo_lego/taterzens/common/storage/TaterConfig.java @@ -1,26 +1,20 @@ -package org.samo_lego.taterzens.storage; +package org.samo_lego.taterzens.common.storage; import com.google.gson.annotations.SerializedName; import org.samo_lego.config2brigadier.IBrigadierConfigurator; import org.samo_lego.config2brigadier.annotation.BrigadierDescription; import org.samo_lego.config2brigadier.annotation.BrigadierExcluded; -import org.samo_lego.taterzens.Taterzens; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.Writer; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; + +import java.io.*; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import static org.samo_lego.taterzens.Taterzens.GSON; -import static org.samo_lego.taterzens.Taterzens.LOGGER; -import static org.samo_lego.taterzens.Taterzens.MOD_ID; +import static com.mojang.text2speech.Narrator.LOGGER; +import static org.samo_lego.taterzens.common.Taterzens.GSON; +import static org.samo_lego.taterzens.common.Taterzens.MOD_ID; public class TaterConfig implements IBrigadierConfigurator { @@ -165,7 +159,7 @@ public static class Permissions { } /** - * Default {@link org.samo_lego.taterzens.npc.TaterzenNPC} settings. + * Default {@link TaterzenNPC} settings. */ public static class Defaults { /** diff --git a/common/src/main/java/org/samo_lego/taterzens/util/LanguageUtil.java b/src/main/java/org/samo_lego/taterzens/common/util/LanguageUtil.java similarity index 86% rename from common/src/main/java/org/samo_lego/taterzens/util/LanguageUtil.java rename to src/main/java/org/samo_lego/taterzens/common/util/LanguageUtil.java index af2445c39..9804a80df 100644 --- a/common/src/main/java/org/samo_lego/taterzens/util/LanguageUtil.java +++ b/src/main/java/org/samo_lego/taterzens/common/util/LanguageUtil.java @@ -1,10 +1,10 @@ -package org.samo_lego.taterzens.util; +package org.samo_lego.taterzens.common.util; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import org.apache.commons.io.IOUtils; -import org.samo_lego.taterzens.Taterzens; +import org.samo_lego.taterzens.common.Taterzens; import javax.net.ssl.HttpsURLConnection; import java.io.BufferedReader; @@ -18,11 +18,11 @@ import java.util.List; import static org.apache.logging.log4j.LogManager.getLogger; -import static org.samo_lego.taterzens.Taterzens.*; +import static org.samo_lego.taterzens.common.Taterzens.*; public class LanguageUtil { - public static final InputStream DEFAULT_LANG_STREAM = Taterzens.class.getResourceAsStream("/data/taterzens/lang/en_us.json"); + public static final InputStream DEFAULT_LANG_STREAM = Taterzens.class.getResourceAsStream("/lang/en_us.json"); public static final List LANG_LIST = new ArrayList<>(); private static final String API_URL = "https://api.github.com/repos/samolego/taterzens/contents/common/src/main/resources/data/taterzens/lang"; private static final String LANG_FILE_URL = "https://raw.githubusercontent.com/samolego/Taterzens/master/common/src/main/resources/data/taterzens/lang/%s.json"; @@ -31,16 +31,16 @@ public class LanguageUtil { * Initializes the mod's language json object. */ public static void setupLanguage() { - String langPath = String.format("/data/taterzens/lang/%s.json", config.language); + String langPath = String.format("/lang/%s.json", config.language); InputStream stream = Taterzens.class.getResourceAsStream(langPath); - if(stream == null) { + if (stream == null) { // Try to fetch language, as it's not present in jar try { final URL url = new URL(String.format(LANG_FILE_URL, config.language)); HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); int responseCode = conn.getResponseCode(); - if(responseCode == HttpURLConnection.HTTP_OK) { + if (responseCode == HttpURLConnection.HTTP_OK) { LanguageUtil.loadLanguageFile(conn.getInputStream()); } else { getLogger("Taterzens").error("Got {} when trying to fetch {} from {}.", responseCode, config.language, url); @@ -54,7 +54,7 @@ public static void setupLanguage() { } conn.disconnect(); - } catch(IOException e) { + } catch (IOException e) { e.printStackTrace(); } @@ -84,11 +84,11 @@ public static JsonObject loadLanguageFile(InputStream inputStream) { final URL REPO_API_URL = new URL(API_URL); String ending = ".json"; HttpsURLConnection conn = (HttpsURLConnection) REPO_API_URL.openConnection(); - if(conn.getResponseCode() == HttpURLConnection.HTTP_OK) { + if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { String reply = IOUtils.toString(new InputStreamReader(conn.getInputStream())); JsonArray json = GSON.fromJson(reply, JsonArray.class); - for(JsonElement element : json) { + for (JsonElement element : json) { JsonObject file = element.getAsJsonObject(); String langName = file.get("name").getAsString(); @@ -99,7 +99,7 @@ public static JsonObject loadLanguageFile(InputStream inputStream) { } conn.disconnect(); - } catch(IOException e) { + } catch (IOException e) { e.printStackTrace(); } } diff --git a/common/src/main/java/org/samo_lego/taterzens/util/TextUtil.java b/src/main/java/org/samo_lego/taterzens/common/util/TextUtil.java similarity index 74% rename from common/src/main/java/org/samo_lego/taterzens/util/TextUtil.java rename to src/main/java/org/samo_lego/taterzens/common/util/TextUtil.java index 181e6c29d..4eed6f652 100644 --- a/common/src/main/java/org/samo_lego/taterzens/util/TextUtil.java +++ b/src/main/java/org/samo_lego/taterzens/common/util/TextUtil.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.util; +package org.samo_lego.taterzens.common.util; import com.google.gson.JsonElement; import com.google.gson.JsonParser; @@ -8,13 +8,13 @@ import net.minecraft.nbt.Tag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; -import net.minecraft.network.chat.contents.LiteralContents; +import net.minecraft.network.chat.contents.PlainTextContents; import net.minecraft.network.chat.contents.TranslatableContents; import java.util.Arrays; -import static org.samo_lego.taterzens.Taterzens.lang; -import static org.samo_lego.taterzens.compatibility.ModDiscovery.SERVER_TRANSLATIONS_LOADED; +import static org.samo_lego.taterzens.common.compatibility.ModDiscovery.SERVER_TRANSLATIONS_LOADED; +import static org.samo_lego.taterzens.common.Taterzens.lang; public class TextUtil { @@ -40,7 +40,7 @@ public static MutableComponent errorText(String key, String... insertedText) { * @return NbtElement generated from text. */ public static Tag toNbtElement(Component text) { - JsonElement json = JsonParser.parseString(Component.Serializer.toJson(text)); + JsonElement json = JsonParser.parseString(Component.Serializer.toJson(text, null)); return JsonOps.INSTANCE.convertTo(NbtOps.INSTANCE, json); } @@ -51,19 +51,25 @@ public static Tag toNbtElement(Component text) { */ public static MutableComponent fromNbtElement(Tag textNbtElement) { JsonElement json = NbtOps.INSTANCE.convertTo(JsonOps.INSTANCE, textNbtElement); - return Component.Serializer.fromJson(json); + return Component.Serializer.fromJson(json, null); } /** * Gets the text for the given language key. * * @param key lang key. - * @return {@link TranslatableContents} or {@link LiteralContents} depending on whether SERVER_TRANSLATIONS is loaded. + * @return {@link TranslatableContents} or {@link PlainTextContents.LiteralContents} depending on whether SERVER_TRANSLATIONS is loaded. */ public static MutableComponent translate(String key, Object... args) { + /* + + // Commenting this out because SERVER_TRANSLATIONS doesn't seem to do anything, particularly when we have translation files available and loaded + // Because this always seems to be loaded, it's always going to prevent the follow on translation thanks to that return... + if (SERVER_TRANSLATIONS_LOADED) { return Component.translatable(key, args); } + */ String translation; if (lang.has(key)) { diff --git a/common/src/main/java/org/samo_lego/taterzens/util/WebUtil.java b/src/main/java/org/samo_lego/taterzens/common/util/WebUtil.java similarity index 97% rename from common/src/main/java/org/samo_lego/taterzens/util/WebUtil.java rename to src/main/java/org/samo_lego/taterzens/common/util/WebUtil.java index 48ec60bde..3480e64b2 100644 --- a/common/src/main/java/org/samo_lego/taterzens/util/WebUtil.java +++ b/src/main/java/org/samo_lego/taterzens/common/util/WebUtil.java @@ -1,4 +1,4 @@ -package org.samo_lego.taterzens.util; +package org.samo_lego.taterzens.common.util; import org.jetbrains.annotations.Nullable; diff --git a/fabric/src/main/java/org/samo_lego/taterzens/fabric/TaterzensFabric.java b/src/main/java/org/samo_lego/taterzens/fabric/TaterzensFabric.java similarity index 84% rename from fabric/src/main/java/org/samo_lego/taterzens/fabric/TaterzensFabric.java rename to src/main/java/org/samo_lego/taterzens/fabric/TaterzensFabric.java index 291929dd9..31b883339 100644 --- a/fabric/src/main/java/org/samo_lego/taterzens/fabric/TaterzensFabric.java +++ b/src/main/java/org/samo_lego/taterzens/fabric/TaterzensFabric.java @@ -6,17 +6,16 @@ import net.fabricmc.fabric.api.event.player.UseBlockCallback; import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry; import net.minecraft.core.registries.BuiltInRegistries; -import org.samo_lego.taterzens.Taterzens; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import org.samo_lego.taterzens.fabric.commands.MessagesReorderCommand; import org.samo_lego.taterzens.fabric.compatibility.carpet.AdditionalFunctions; -import org.samo_lego.taterzens.fabric.compatibility.carpet.ScarpetProfession; import org.samo_lego.taterzens.fabric.compatibility.carpet.ScarpetTraitCommand; import org.samo_lego.taterzens.fabric.event.BlockInteractEventImpl; import org.samo_lego.taterzens.fabric.platform.FabricPlatform; -import org.samo_lego.taterzens.npc.TaterzenNPC; -import static org.samo_lego.taterzens.Taterzens.TATERZEN_TYPE; -import static org.samo_lego.taterzens.compatibility.ModDiscovery.CARPETMOD_LOADED; +import static org.samo_lego.taterzens.common.Taterzens.TATERZEN_TYPE; +import static org.samo_lego.taterzens.common.compatibility.ModDiscovery.CARPETMOD_LOADED; public class TaterzensFabric implements ModInitializer { diff --git a/fabric/src/main/java/org/samo_lego/taterzens/fabric/commands/MessagesReorderCommand.java b/src/main/java/org/samo_lego/taterzens/fabric/commands/MessagesReorderCommand.java similarity index 87% rename from fabric/src/main/java/org/samo_lego/taterzens/fabric/commands/MessagesReorderCommand.java rename to src/main/java/org/samo_lego/taterzens/fabric/commands/MessagesReorderCommand.java index 2883f6755..98c4fdb63 100644 --- a/fabric/src/main/java/org/samo_lego/taterzens/fabric/commands/MessagesReorderCommand.java +++ b/src/main/java/org/samo_lego/taterzens/fabric/commands/MessagesReorderCommand.java @@ -6,10 +6,10 @@ import com.mojang.brigadier.tree.LiteralCommandNode; import net.minecraft.commands.CommandSourceStack; import net.minecraft.server.level.ServerPlayer; -import org.samo_lego.taterzens.commands.NpcCommand; +import org.samo_lego.taterzens.common.commands.NpcCommand; import org.samo_lego.taterzens.fabric.gui.MessagesEditGUI; -import static org.samo_lego.taterzens.commands.edit.messages.MessagesCommand.messagesNode; +import static org.samo_lego.taterzens.common.commands.edit.messages.MessagesCommand.messagesNode; public class MessagesReorderCommand { public static void register(CommandDispatcher dispatcher) { diff --git a/fabric/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/AdditionalFunctions.java b/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/AdditionalFunctions.java similarity index 91% rename from fabric/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/AdditionalFunctions.java rename to src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/AdditionalFunctions.java index e3d6703e2..a055428db 100644 --- a/fabric/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/AdditionalFunctions.java +++ b/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/AdditionalFunctions.java @@ -5,10 +5,10 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import org.jetbrains.annotations.Nullable; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.api.TaterzensAPI; -import org.samo_lego.taterzens.interfaces.ITaterzenEditor; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.api.TaterzensAPI; +import org.samo_lego.taterzens.common.interfaces.ITaterzenEditor; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.util.UUID; diff --git a/fabric/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/ScarpetProfession.java b/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/ScarpetProfession.java similarity index 94% rename from fabric/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/ScarpetProfession.java rename to src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/ScarpetProfession.java index 1a1ddc454..d2d6b5f89 100644 --- a/fabric/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/ScarpetProfession.java +++ b/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/ScarpetProfession.java @@ -15,14 +15,14 @@ import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.phys.Vec3; -import org.samo_lego.taterzens.api.professions.AbstractProfession; -import org.samo_lego.taterzens.npc.NPCData; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.api.professions.AbstractProfession; +import org.samo_lego.taterzens.common.npc.NPCData; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.util.HashSet; import java.util.List; -import static org.samo_lego.taterzens.Taterzens.MOD_ID; +import static org.samo_lego.taterzens.common.Taterzens.MOD_ID; public class ScarpetProfession extends AbstractProfession { private static final TaterzenScarpetEvent PICKUP_EVENT = new TaterzenScarpetEvent("taterzen_tries_pickup", 3); @@ -39,7 +39,7 @@ public class ScarpetProfession extends AbstractProfession { private static final TaterzenScarpetEvent PLAYERS_NEARBY_EVENT = new TaterzenScarpetEvent("taterzen_approached_by", 3); private final HashSet SCARPET_TRAITS = new HashSet<>(); - public static final ResourceLocation ID = new ResourceLocation(MOD_ID, "scarpet_profession"); + public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(MOD_ID, "scarpet_profession"); public ScarpetProfession(TaterzenNPC npc) { super(npc); diff --git a/fabric/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/ScarpetTraitCommand.java b/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/ScarpetTraitCommand.java similarity index 93% rename from fabric/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/ScarpetTraitCommand.java rename to src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/ScarpetTraitCommand.java index 6af5cf785..563fce49c 100644 --- a/fabric/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/ScarpetTraitCommand.java +++ b/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/ScarpetTraitCommand.java @@ -14,11 +14,11 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.MutableComponent; -import org.samo_lego.taterzens.Taterzens; -import org.samo_lego.taterzens.api.TaterzensAPI; -import org.samo_lego.taterzens.api.professions.TaterzenProfession; -import org.samo_lego.taterzens.commands.NpcCommand; -import org.samo_lego.taterzens.interfaces.ITaterzenEditor; +import org.samo_lego.taterzens.common.Taterzens; +import org.samo_lego.taterzens.common.api.TaterzensAPI; +import org.samo_lego.taterzens.common.api.professions.TaterzenProfession; +import org.samo_lego.taterzens.common.commands.NpcCommand; +import org.samo_lego.taterzens.common.interfaces.ITaterzenEditor; import java.util.HashSet; import java.util.concurrent.CompletableFuture; @@ -26,9 +26,9 @@ import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; -import static org.samo_lego.taterzens.Taterzens.config; -import static org.samo_lego.taterzens.commands.ProfessionCommand.PROFESSION_COMMAND_NODE; -import static org.samo_lego.taterzens.util.TextUtil.*; +import static org.samo_lego.taterzens.common.Taterzens.config; +import static org.samo_lego.taterzens.common.commands.ProfessionCommand.PROFESSION_COMMAND_NODE; +import static org.samo_lego.taterzens.common.util.TextUtil.*; public class ScarpetTraitCommand { static { diff --git a/fabric/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/TaterzenScarpetEvent.java b/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/TaterzenScarpetEvent.java similarity index 96% rename from fabric/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/TaterzenScarpetEvent.java rename to src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/TaterzenScarpetEvent.java index cf94728cf..be53c562e 100644 --- a/fabric/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/TaterzenScarpetEvent.java +++ b/src/main/java/org/samo_lego/taterzens/fabric/compatibility/carpet/TaterzenScarpetEvent.java @@ -9,7 +9,7 @@ import carpet.script.value.ValueConversions; import net.minecraft.server.level.ServerLevel; import org.jetbrains.annotations.NotNull; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.util.ArrayList; import java.util.HashSet; diff --git a/fabric/src/main/java/org/samo_lego/taterzens/fabric/event/BlockInteractEventImpl.java b/src/main/java/org/samo_lego/taterzens/fabric/event/BlockInteractEventImpl.java similarity index 87% rename from fabric/src/main/java/org/samo_lego/taterzens/fabric/event/BlockInteractEventImpl.java rename to src/main/java/org/samo_lego/taterzens/fabric/event/BlockInteractEventImpl.java index 9fd335164..38e32a394 100644 --- a/fabric/src/main/java/org/samo_lego/taterzens/fabric/event/BlockInteractEventImpl.java +++ b/src/main/java/org/samo_lego/taterzens/fabric/event/BlockInteractEventImpl.java @@ -6,7 +6,8 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; -import org.samo_lego.taterzens.event.BlockEvent; +import org.samo_lego.taterzens.common.event.BlockEvent; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; public class BlockInteractEventImpl implements UseBlockCallback { @@ -15,7 +16,7 @@ public BlockInteractEventImpl() { /** * Used if player is in path edit mode. Interacted blocks are removed from the path - * of selected {@link org.samo_lego.taterzens.npc.TaterzenNPC}. + * of selected {@link TaterzenNPC}. * * @param player player breaking the block * @param world world where block is being broken diff --git a/fabric/src/main/java/org/samo_lego/taterzens/fabric/gui/EditorGUI.java b/src/main/java/org/samo_lego/taterzens/fabric/gui/EditorGUI.java similarity index 96% rename from fabric/src/main/java/org/samo_lego/taterzens/fabric/gui/EditorGUI.java rename to src/main/java/org/samo_lego/taterzens/fabric/gui/EditorGUI.java index 53133f3e9..34f5ac862 100644 --- a/fabric/src/main/java/org/samo_lego/taterzens/fabric/gui/EditorGUI.java +++ b/src/main/java/org/samo_lego/taterzens/fabric/gui/EditorGUI.java @@ -20,14 +20,16 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import org.jetbrains.annotations.Nullable; -import org.samo_lego.taterzens.Taterzens; +import org.samo_lego.taterzens.common.Taterzens; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import java.util.UUID; -import static org.samo_lego.taterzens.Taterzens.config; + +import static org.samo_lego.taterzens.common.Taterzens.config; public class EditorGUI { @@ -35,6 +37,10 @@ public class EditorGUI { private static final ItemStack NO_BUTTON = new ItemStack(Items.RED_STAINED_GLASS_PANE); private static final HashMap itemCommandMap = new HashMap<>(); + // TODO: Fix the itemStack implementation to match 1.21 throughout. Otherwise we'll disable the GUI. + + /* + @SuppressWarnings("unchecked") public static SimpleGui createCommandGui(ServerPlayer player, @Nullable SimpleGui previousScreen, CommandNode parentNode, List currentCommandPath, boolean givenInput) { // If node is not an argument, we skip to first child node that is an argument or has more than 1 child node @@ -42,7 +48,7 @@ public static SimpleGui createCommandGui(ServerPlayer player, @Nullable SimpleGu CommandNode childNode = (CommandNode) parentNode.getChildren().toArray()[0]; if (childNode instanceof ArgumentCommandNode) { givenInput = false; - } else if (childNode.getChildren().size() > 0) { + } else if (!childNode.getChildren().isEmpty()) { currentCommandPath.add(parentNode.getName()); } else { break; @@ -160,13 +166,16 @@ public static SimpleGui createCommandGui(ServerPlayer player, @Nullable SimpleGu return constructedGui; } - + */ + /** * Gets prettier name for command node if available. * * @param defaultText default name * @return "translated" name if available, default name otherwise */ + + /* private static Component getComandName(String defaultText) { // Try to search for the command translation in the language file String text = defaultText; @@ -201,13 +210,15 @@ private static void proccessClick(ClickType clickType, CommandNode commandTree) { try { // Execute @@ -375,7 +386,8 @@ private static void execute(ServerPlayer player, List commandTree) { // Types ItemStack player = new ItemStack(Items.PLAYER_HEAD); - GameProfile texturesProfile = new GameProfile(null, "taterzen"); + UUID uid = UUID.randomUUID(); // a fake UUID just to be able to generate GameProfile for Texture use. + GameProfile texturesProfile = new GameProfile(uid, "taterzen"); PropertyMap properties = texturesProfile.getProperties(); properties.put("textures", new Property("ewogICJ0aW1lc3RhbXAiIDogMTYwNjIyODAxMzY0NCwKICAicHJvZmlsZUlkIiA6ICJiMGQ0YjI4YmMxZDc0ODg5YWYwZTg2NjFjZWU5NmFhYiIsCiAgInByb2ZpbGVOYW1lIiA6ICJNaW5lU2tpbl9vcmciLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTczNTE0YTIzMjQ1ZjE1ZGJhZDVmYjRlNjIyMTYzMDIwODY0Y2NlNGMxNWQ1NmRlM2FkYjkwZmE1YTcxMzdmZCIKICAgIH0KICB9Cn0=", "T4Mifh5Yr/+jjAe6y+Ai7d1BPIWQGXc6vwtDL9GgxvQFYtxeD2VuSMNniLoSkP5koBDyHE9ZLgzE2GGAbBSGFgdEKBK7stUPEaUhCET6NKQGli369my3t4Z/4fTkFd9lJmMjP84xIo33E69umQLRZN6MfxmAFXdAl0fkjBdpVi3zLsTdgyu01PhlF9/P4TMXJmNjeiUDt6IjdHgWN1UVFYfAMr9UnCvBNQ/Z4MzxXEm8lGrhq0u7piZqJZ4hb15vHVfixXwtJQkJSBxyzry2W9ZZ2l4xReYX4LbBxU2mRVY5ylRbbolpDuMjXJ6vcg+hRQ9c5HhKkYLm/GOloYEHF/LA5FjGD0QGPW/+uzPfFc9b9swdTUXrJS18/d0dYUDvnHWacDuSoQDfb9eszvs4p6JW04Kd/fPAjLrHm36itVgmrkGa4+fA0Sd/3qo3JaRN6rkbzvppc9s7T2jrhz2+h+hSiiXdRv7v1vMhHVFaOayzBmckL+aKcq7HEsDg1MMauoA/OzkWekuk4FqbgZz49nylOcCHVfd7X1SO7D1BicTgdvGGTOVZtYCyfMKCxcxXFgcqQe88BcLujYWsWafO+VPer9RykXAStb80L020KA0FsQ3zOIC0SBgGlTH5E2Z66AyBEcevYqfIUu1G6Gq4uWINrMae4ZKAABOhtoWH+1Y=")); player.setTag(customData.copy()); @@ -387,4 +399,5 @@ private static void execute(ServerPlayer player, List commandTree) { itemCommandMap.put("player", player); itemCommandMap.put("reset", player); } + */ } diff --git a/fabric/src/main/java/org/samo_lego/taterzens/fabric/gui/ListItemsGUI.java b/src/main/java/org/samo_lego/taterzens/fabric/gui/ListItemsGUI.java similarity index 96% rename from fabric/src/main/java/org/samo_lego/taterzens/fabric/gui/ListItemsGUI.java rename to src/main/java/org/samo_lego/taterzens/fabric/gui/ListItemsGUI.java index e0e53b7ad..d7478c11b 100644 --- a/fabric/src/main/java/org/samo_lego/taterzens/fabric/gui/ListItemsGUI.java +++ b/src/main/java/org/samo_lego/taterzens/fabric/gui/ListItemsGUI.java @@ -13,9 +13,9 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import org.samo_lego.taterzens.Taterzens; +import org.samo_lego.taterzens.common.Taterzens; -import static org.samo_lego.taterzens.Taterzens.config; +import static org.samo_lego.taterzens.common.Taterzens.config; public abstract class ListItemsGUI extends SimpleGui implements Container { protected static final CompoundTag customData = new CompoundTag(); @@ -34,6 +34,9 @@ public ListItemsGUI(ServerPlayer player, Component npcName, String titleTranslat this.setTitle(Component.translatable(titleTranslationKey).append(": ").withStyle(ChatFormatting.YELLOW).append(npcName.copy())); + // TODO: Fix this to meet the 1.21 itemStack implementation + + /* // Info (which page) ItemStack info = new ItemStack(Items.PAPER); info.setTag(customData.copy()); @@ -80,6 +83,7 @@ public ListItemsGUI(ServerPlayer player, Component npcName, String titleTranslat player.closeContainer(); }); this.setSlot(8, closeScreenButton); + */ } /** diff --git a/fabric/src/main/java/org/samo_lego/taterzens/fabric/gui/MessagesEditGUI.java b/src/main/java/org/samo_lego/taterzens/fabric/gui/MessagesEditGUI.java similarity index 85% rename from fabric/src/main/java/org/samo_lego/taterzens/fabric/gui/MessagesEditGUI.java rename to src/main/java/org/samo_lego/taterzens/fabric/gui/MessagesEditGUI.java index 626cb9b1e..a8a711853 100644 --- a/fabric/src/main/java/org/samo_lego/taterzens/fabric/gui/MessagesEditGUI.java +++ b/src/main/java/org/samo_lego/taterzens/fabric/gui/MessagesEditGUI.java @@ -4,11 +4,11 @@ import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.item.ItemStack; -import org.samo_lego.taterzens.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; import java.util.List; -import static org.samo_lego.taterzens.Taterzens.config; +import static org.samo_lego.taterzens.common.Taterzens.config; public class MessagesEditGUI extends ListItemsGUI { private final List> messages; @@ -34,8 +34,11 @@ public MessagesEditGUI(ServerPlayer player, TaterzenNPC taterzen) { private ItemStack getItem(Pair pair) { Component message = pair.getFirst(); ItemStack itemStack = new ItemStack(getFromName(message.getString())); - itemStack.setTag(customData.copy()); - itemStack.setHoverName(message); + + // TODO: Fix the itemStack implementation to meet 1.21 standard + + //itemStack.setTag(customData.copy()); + //itemStack.setHoverName(message); return itemStack; } @@ -65,7 +68,10 @@ public ItemStack removeItemNoUpdate(int index) { index = this.getActualPageIndex(index); if(index < this.messages.size()) { Pair removed = this.messages.remove(index); - itemStack.setHoverName(this.getItem(removed).getHoverName()); + + // TODO: Fix the itemStack implementation to meet 1.21 standard + + //itemStack.setHoverName(this.getItem(removed).getHoverName()); } return itemStack; diff --git a/fabric/src/main/java/org/samo_lego/taterzens/fabric/gui/RedirectedSlot.java b/src/main/java/org/samo_lego/taterzens/fabric/gui/RedirectedSlot.java similarity index 100% rename from fabric/src/main/java/org/samo_lego/taterzens/fabric/gui/RedirectedSlot.java rename to src/main/java/org/samo_lego/taterzens/fabric/gui/RedirectedSlot.java diff --git a/fabric/src/main/java/org/samo_lego/taterzens/fabric/mixin/AMappedRegistry.java b/src/main/java/org/samo_lego/taterzens/fabric/mixin/AMappedRegistry.java similarity index 100% rename from fabric/src/main/java/org/samo_lego/taterzens/fabric/mixin/AMappedRegistry.java rename to src/main/java/org/samo_lego/taterzens/fabric/mixin/AMappedRegistry.java diff --git a/fabric/src/main/java/org/samo_lego/taterzens/fabric/platform/FabricPlatform.java b/src/main/java/org/samo_lego/taterzens/fabric/platform/FabricPlatform.java similarity index 74% rename from fabric/src/main/java/org/samo_lego/taterzens/fabric/platform/FabricPlatform.java rename to src/main/java/org/samo_lego/taterzens/fabric/platform/FabricPlatform.java index 9d2c0029d..d301a87c5 100644 --- a/fabric/src/main/java/org/samo_lego/taterzens/fabric/platform/FabricPlatform.java +++ b/src/main/java/org/samo_lego/taterzens/fabric/platform/FabricPlatform.java @@ -12,20 +12,24 @@ import net.minecraft.world.entity.EntityDimensions; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; +import org.samo_lego.taterzens.common.npc.TaterzenNPC; +import org.samo_lego.taterzens.common.platform.Platform; import org.samo_lego.taterzens.fabric.mixin.AMappedRegistry; -import org.samo_lego.taterzens.npc.TaterzenNPC; -import org.samo_lego.taterzens.platform.Platform; -import xyz.nucleoid.disguiselib.api.EntityDisguise; import java.nio.file.Path; import java.util.Collections; -import static org.samo_lego.taterzens.Taterzens.NPC_ID; -import static org.samo_lego.taterzens.Taterzens.TATERZEN_TYPE; -import static org.samo_lego.taterzens.commands.NpcCommand.npcNode; -import static org.samo_lego.taterzens.fabric.gui.EditorGUI.createCommandGui; +import static org.samo_lego.taterzens.common.Taterzens.NPC_ID; +import static org.samo_lego.taterzens.common.Taterzens.TATERZEN_TYPE; +import static org.samo_lego.taterzens.common.commands.NpcCommand.npcNode; +// Commented out for now as the EditorGUI is being temporarily disable +//import static org.samo_lego.taterzens.fabric.gui.EditorGUI.createCommandGui; +import eu.pb4.polymer.core.api.entity.PolymerEntity; -public class FabricPlatform extends Platform { + + + +public class FabricPlatform implements Platform { private static final int REGISTRY_ITEMS_SIZE = ((AMappedRegistry) BuiltInRegistries.ITEM).getById().size(); @@ -77,18 +81,19 @@ public void registerTaterzenType() { @Override public void openEditorGui(ServerPlayer player) { - SimpleGui editorGUI = createCommandGui(player, null, npcNode, Collections.singletonList("npc"), false); - editorGUI.open(); + // Commenting out since we've disabled the Editor GUI for now with the 1.21 update + // SimpleGui editorGUI = createCommandGui(player, null, npcNode, Collections.singletonList("npc"), false); + //editorGUI.open(); } @Override public void disguiseAs(TaterzenNPC taterzen, Entity entity) { - ((EntityDisguise) taterzen).disguiseAs(entity); + //todo ((EntityDisguise) taterzen).disguiseAs(entity); } @Override public void clearDisguise(TaterzenNPC taterzen) { - ((EntityDisguise) taterzen).removeDisguise(); + //todo ((EntityDisguise) taterzen).removeDisguise(); } } diff --git a/fabric/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json similarity index 95% rename from fabric/src/main/resources/fabric.mod.json rename to src/main/resources/fabric.mod.json index d29f4242b..bd4928f0d 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -22,7 +22,7 @@ "org.samo_lego.taterzens.fabric.TaterzensFabric" ], "client": [ - "org.samo_lego.taterzens.fabric.client_fix.ClientInit" + "org.samo_lego.taterzens.client.TaterzensClient" ] }, "mixins": [ diff --git a/common/src/main/resources/data/taterzens/lang/en_us.json b/src/main/resources/lang/en_us.json similarity index 100% rename from common/src/main/resources/data/taterzens/lang/en_us.json rename to src/main/resources/lang/en_us.json diff --git a/common/src/main/resources/data/taterzens/lang/pt_br.json b/src/main/resources/lang/pt_br.json similarity index 100% rename from common/src/main/resources/data/taterzens/lang/pt_br.json rename to src/main/resources/lang/pt_br.json diff --git a/common/src/main/resources/data/taterzens/lang/ro_ro.json b/src/main/resources/lang/ro_ro.json similarity index 100% rename from common/src/main/resources/data/taterzens/lang/ro_ro.json rename to src/main/resources/lang/ro_ro.json diff --git a/common/src/main/resources/data/taterzens/lang/sl_si.json b/src/main/resources/lang/sl_si.json similarity index 100% rename from common/src/main/resources/data/taterzens/lang/sl_si.json rename to src/main/resources/lang/sl_si.json diff --git a/common/src/main/resources/data/taterzens/lang/zh_cn.json b/src/main/resources/lang/zh_cn.json similarity index 98% rename from common/src/main/resources/data/taterzens/lang/zh_cn.json rename to src/main/resources/lang/zh_cn.json index afe0185d9..e57b8330a 100644 --- a/common/src/main/resources/data/taterzens/lang/zh_cn.json +++ b/src/main/resources/lang/zh_cn.json @@ -1,132 +1,132 @@ -{ - "advert.fabrictailor": "如果想为NPC设置更多皮肤,请安装“离线皮肤切换”(Fabric Tailor)模组。", - "advert.fabrictailor.skin_command": "如果想为NPC设置更多皮肤,请使用“离线皮肤切换”(Fabric Tailor)模组的‘/skin’指令。", - "advert.disguiselib.required": "要想执行此操作,需要安装“DisguiseLib”模组。", - "advert.tooltip.install": "安装:%s。", - "taterzens.misc.current_value": "当前值:%s", - "taterzens.misc.type": "类型:%s", - "taterzens.command.action.interact.success": "名为%s的NPC与%s方块进行了交互。", - "taterzens.command.action.interact.fail": "坐标%s太远了。", - "taterzens.command.action.goto.success": "名为%s的NPC即将前往%s坐标。", - "taterzens.command.message.editor.enter": "你已进入%s的信息编辑界面,请输入相同的指令退出编辑。", - "taterzens.command.message.editor.desc.1": "请在聊天栏中发送信息,名为%s的NPC将会重复发送该信息。", - "taterzens.command.message.editor.desc.2": "你可以发送普通的文本,也可以使用基于/tellraw指令的JSON颜色文本。", - "taterzens.command.message.editor.add": "信息%s已成功添加。", - "taterzens.command.message.list": "名为%s的NPC拥有以下可编辑的信息,请点击其中一个来编辑。", - "taterzens.command.message.edit": "你目前正在编辑信息:%s,编辑完成后按下回车键即可保存。", - "taterzens.command.message.clear": "%sNPC的信息已被清除。", - "taterzens.command.message.delay": "%s和%s的信息延迟已被设置为%stick。", - "taterzens.command.message.changed": "信息已更改为%s。", - "taterzens.command.message.deleted": "信息%s已成功删除。", - "taterzens.command.message.error.404": "未发现id为%s的信息。", - "taterzens.command.message.swapped": "信息%s和%s已互换。", - "taterzens.command.equipment.enter": "你已进入%s的装备编辑界面,请输入相同的指令退出编辑。", - "taterzens.command.equipment.desc.1": "手持装备/武器对着NPC右键即可让NPC手持或者穿戴。", - "taterzens.command.equipment.desc.2": "对着NPC左键即可交换主副手上的物品。", - "taterzens.command.equipment.desc.3": "手持装备对着NPC按住Shift键+右键可让NPC手持装备。", - "taterzens.command.equipment.desc.4": "空手对着NPC然后按下Shift+右键可清空NPC身上所有的装备。", - "taterzens.command.equipment.exit": "你已退出编辑界面。", - "taterzens.command.equipment.drop_mode.set": "装备掉落已设置为%s。", - "taterzens.command.commands.cooldown.edit_message": "成功将%s的信息冷却时间设置为%s。", - "taterzens.command.commands.cooldown.set": "成功将%s的指令冷却时间设置为%s。", - "taterzens.command.commands.list": "名为%s的NPC将会在玩家对其右键时执行以下指令。", - "taterzens.command.commands.listBungee": "同时也可以设置以下跨服(bungee)指令。", - "taterzens.command.commands.set": "成功添加指令:%s。", - "taterzens.command.commands.setBungee": "成功添加跨服(bungee)指令:%s。", - "taterzens.command.commands.permission.set": "该执行指令的权限等级已被设置为%s级。", - "taterzens.command.commands.cleared": "%s的指令已被清除。", - "taterzens.command.commands.removed": "指令%s已成功删除。", - "taterzens.command.commands.error.404": "未找到id为%s的指令。", - "taterzens.command.commands.group.removed": "指令组%s已成功删除。", - "taterzens.command.commands.error.group.404": "未找到id为%s的指令组。", - "taterzens.command.commands.group.cleared": "指令组%s的指令已被清除。", - "taterzens.command.commands.group.created": "成功将索引切换到%s新建指令组。", - "taterzens.command.commands.group": "指令组%s:", - "taterzens.command.preset.export.success": "NPC已导出到%s。", - "taterzens.command.preset.import.success": "NPC已从%s中加载。", - "taterzens.command.preset.import.error.malformed": "无法读取预设%s。", - "taterzens.command.preset.import.error.404": "未找到名为%s的NPC预设。", - "taterzens.command.path_editor.enter": "你已进入%s的路径编辑界面,请输入相同的指令退出编辑。", - "taterzens.command.path_editor.desc.1": "左键点击方块,将其添加到路径中。", - "taterzens.command.path_editor.desc.2": "右键点击方块,将其从路径中删除。", - "taterzens.command.path_editor.clear": "%s路径已被清除。", - "taterzens.command.profession.add": "职业%s已成功添加。", - "taterzens.command.profession.remove": "职业%s已成功删除。", - "taterzens.command.profession.error.404": "未找到id为%s的职业。", - "taterzens.command.profession.list": "NPC%s有以下可设置的职业,点击“X”可删除一个。", - "taterzens.profession.lacking": "NPC缺少%s职业。", - "taterzens.command.trait.add": "属性%s已成功添加。", - "taterzens.command.trait.remove": "属性%s已成功删除。", - "taterzens.command.trait.error.404": "未找到id为%s的属性。", - "taterzens.command.trait.list": "NPC%s有以下可设置的属性,点击“X”可删除一个。", - "taterzens.command.pose": "NPC的姿势已被设置为%s。", - "taterzens.command.respawn.toggle": "NPC的生成规则已被设置为%s。", - "taterzens.command.movement.set": "移动类型已被设置为%s。", - "taterzens.command.movement.follow.set": "NPC的跟随目标已被设置为%s。", - "taterzens.command.movement.follow.error.uuid": "跟随类型%s需要设置目标的UUID参数。", - "taterzens.command.entity_type.set": "NPC实体类型已被设置为%s。", - "taterzens.command.entity_type.reset": "实体类型%s已重置为默认值。", - "taterzens.command.behaviour.set": "行为方式已被设置为%s。", - "taterzens.command.behaviour.suggest.invulnerable.false": "点击此处可关闭NPC的无敌模式。", - "taterzens.command.skin.fetched": "NPC的皮肤已从%s中获取。", - "taterzens.command.skin.error": "无法从%s中获取皮肤。", - "taterzens.command.skin.mirrored": "NPC%s的皮肤已成功镜像。", - "taterzens.command.select": "你已选择%s。", - "taterzens.command.deselect": "你目前并没有选择任何NPC。", - "taterzens.command.create": "名为%s的NPC已成功生成。", - "taterzens.command.remove": "名为%s的NPC已成功删除。", - "taterzens.command.list": "NPC列表:", - "taterzens.command.lock.success": "名为%s的NPC已锁定。", - "taterzens.command.unlock.success": "名为%s的NPC已解锁。", - "taterzens.command.error.locked": "名为%s的NPC已被锁定,无法编辑。", - "taterzens.command.mount": "名为%s的NPC正在骑乘%s。", - "taterzens.command.umount": "名为%s的NPC目前没有骑乘任何生物。", - "taterzens.command.tags.changed": "Tag标签%s已被更改为%s。", - "taterzens.command.tags.hide_name_hint.desc.1": "NPC的名称已被设置为%s,姿势被设置为%s,以确保可以隐藏其名称。", - "taterzens.command.tags.hide_name_hint.desc.2": "如果想保留NPC的名称,请将%s添加到自定义的团队里,然后更改其在团队中的位置。", - "taterzens.command.config.success": "已成功重载配置文件。", - "taterzens.command.rename.success": "已成功将NPC的名称重命名为%s。", - "taterzens.command.language.success": "已成功获取语言文件并将语言切换至%s。", - "taterzens.command.language.server_translations_hint.1": "你目前使用的是来自服务器的语言模组,不会产生任何影响。", - "taterzens.command.language.server_translations_hint.2": "除非更改客户端的语言。", - "taterzens.command.language.error": "尝试获取语言文件%s时发生了错误。", - "taterzens.command.language.404": "语言文件%s不可用,你愿意帮助翻译吗?如果想的话请访问%s获取更多信息。", - "taterzens.command.wiki": "访问%s文档。", - "taterzens.command.sounds.404": "声音材质包%s在NPC的%s中的声音是不可用的。", - "taterzens.command.sounds.ambient": "环境", - "taterzens.command.sounds.hurt": "受伤", - "taterzens.command.sounds.death": "死亡", - "taterzens.command.sounds.invalid": "无效的声音路径。", - "taterzens.command.sounds.list.ambient": "目前设置的环境声音:", - "taterzens.command.sounds.list.hurt": "目前设置的受伤声音:", - "taterzens.command.sounds.list.death": "目前设置的死亡声音:", - "taterzens.command.sounds.list.empty": "未设置任何声音。", - "taterzens.command.sounds.add.success": "声音%s已成功添加。", - "taterzens.command.sounds.add.failure": "声音%s添加失败。", - "taterzens.command.sounds.remove.success": "声音%s已成功删除。", - "taterzens.command.sounds.remove.failure": "声音%s无法被删除。", - "taterzens.command.sounds.remove.outofbounds": "无法删除索引为%s的声音,最低索引为%s,最高索引为%s。", - "taterzens.command.sounds.remove.all.success": "所有%s的声音已成功被删除。", - "taterzens.command.sounds.remove.all.failure": "无法删除所有%s声音。", - "taterzens.gui.forge": "本模组的Forge版本不支持GUI,请安装本模组的Fabric版本。", - "taterzens.npc.interact.cooldown": "你需要等待%s秒后才能再次与我互动。", - "taterzens.tooltip.current_editor": "正在编辑:%s。", - "taterzens.tooltip.see_docs": "前往查看文档", - "taterzens.tooltip.see_uuid": "查看UUID", - "taterzens.tooltip.new_selection": "选择%s。", - "taterzens.tooltip.current_selection": "目前已选择:%s.", - "taterzens.tooltip.delete": "删除%s。", - "taterzens.tooltip.edit": "编辑%s。", - "taterzens.tooltip.disable_invulnerability": "关闭无敌", - "taterzens.tooltip.exit": "退出", - "taterzens.error.invalid.url": "URL%s是无效的。", - "taterzens.error.invalid.text": "你输入的NBT文本是无效的。", - "taterzens.error.404.detected": "在你面前未检测到NPC。", - "taterzens.error.404.id": "未找到id为%s的NPC。", - "taterzens.error.404.name": "未找到名称为%s的NPC。", - "taterzens.error.404.uuid": "未找到UUID为%s的NPC。", - "taterzens.error.multiple.name": "在你的附近存在多个名称为%s的NPC。", - "taterzens.error.select": "请先选择一名NPC!", - "taterzens.error.permission": "该操作要求的权限等级%s高于你目前的权限等级。", - "taterzens.error.enableBungee": "请在配置文件中开启支持bungee,否则其将无法生效。" +{ + "advert.fabrictailor": "如果想为NPC设置更多皮肤,请安装“离线皮肤切换”(Fabric Tailor)模组。", + "advert.fabrictailor.skin_command": "如果想为NPC设置更多皮肤,请使用“离线皮肤切换”(Fabric Tailor)模组的‘/skin’指令。", + "advert.disguiselib.required": "要想执行此操作,需要安装“DisguiseLib”模组。", + "advert.tooltip.install": "安装:%s。", + "taterzens.misc.current_value": "当前值:%s", + "taterzens.misc.type": "类型:%s", + "taterzens.command.action.interact.success": "名为%s的NPC与%s方块进行了交互。", + "taterzens.command.action.interact.fail": "坐标%s太远了。", + "taterzens.command.action.goto.success": "名为%s的NPC即将前往%s坐标。", + "taterzens.command.message.editor.enter": "你已进入%s的信息编辑界面,请输入相同的指令退出编辑。", + "taterzens.command.message.editor.desc.1": "请在聊天栏中发送信息,名为%s的NPC将会重复发送该信息。", + "taterzens.command.message.editor.desc.2": "你可以发送普通的文本,也可以使用基于/tellraw指令的JSON颜色文本。", + "taterzens.command.message.editor.add": "信息%s已成功添加。", + "taterzens.command.message.list": "名为%s的NPC拥有以下可编辑的信息,请点击其中一个来编辑。", + "taterzens.command.message.edit": "你目前正在编辑信息:%s,编辑完成后按下回车键即可保存。", + "taterzens.command.message.clear": "%sNPC的信息已被清除。", + "taterzens.command.message.delay": "%s和%s的信息延迟已被设置为%stick。", + "taterzens.command.message.changed": "信息已更改为%s。", + "taterzens.command.message.deleted": "信息%s已成功删除。", + "taterzens.command.message.error.404": "未发现id为%s的信息。", + "taterzens.command.message.swapped": "信息%s和%s已互换。", + "taterzens.command.equipment.enter": "你已进入%s的装备编辑界面,请输入相同的指令退出编辑。", + "taterzens.command.equipment.desc.1": "手持装备/武器对着NPC右键即可让NPC手持或者穿戴。", + "taterzens.command.equipment.desc.2": "对着NPC左键即可交换主副手上的物品。", + "taterzens.command.equipment.desc.3": "手持装备对着NPC按住Shift键+右键可让NPC手持装备。", + "taterzens.command.equipment.desc.4": "空手对着NPC然后按下Shift+右键可清空NPC身上所有的装备。", + "taterzens.command.equipment.exit": "你已退出编辑界面。", + "taterzens.command.equipment.drop_mode.set": "装备掉落已设置为%s。", + "taterzens.command.commands.cooldown.edit_message": "成功将%s的信息冷却时间设置为%s。", + "taterzens.command.commands.cooldown.set": "成功将%s的指令冷却时间设置为%s。", + "taterzens.command.commands.list": "名为%s的NPC将会在玩家对其右键时执行以下指令。", + "taterzens.command.commands.listBungee": "同时也可以设置以下跨服(bungee)指令。", + "taterzens.command.commands.set": "成功添加指令:%s。", + "taterzens.command.commands.setBungee": "成功添加跨服(bungee)指令:%s。", + "taterzens.command.commands.permission.set": "该执行指令的权限等级已被设置为%s级。", + "taterzens.command.commands.cleared": "%s的指令已被清除。", + "taterzens.command.commands.removed": "指令%s已成功删除。", + "taterzens.command.commands.error.404": "未找到id为%s的指令。", + "taterzens.command.commands.group.removed": "指令组%s已成功删除。", + "taterzens.command.commands.error.group.404": "未找到id为%s的指令组。", + "taterzens.command.commands.group.cleared": "指令组%s的指令已被清除。", + "taterzens.command.commands.group.created": "成功将索引切换到%s新建指令组。", + "taterzens.command.commands.group": "指令组%s:", + "taterzens.command.preset.export.success": "NPC已导出到%s。", + "taterzens.command.preset.import.success": "NPC已从%s中加载。", + "taterzens.command.preset.import.error.malformed": "无法读取预设%s。", + "taterzens.command.preset.import.error.404": "未找到名为%s的NPC预设。", + "taterzens.command.path_editor.enter": "你已进入%s的路径编辑界面,请输入相同的指令退出编辑。", + "taterzens.command.path_editor.desc.1": "左键点击方块,将其添加到路径中。", + "taterzens.command.path_editor.desc.2": "右键点击方块,将其从路径中删除。", + "taterzens.command.path_editor.clear": "%s路径已被清除。", + "taterzens.command.profession.add": "职业%s已成功添加。", + "taterzens.command.profession.remove": "职业%s已成功删除。", + "taterzens.command.profession.error.404": "未找到id为%s的职业。", + "taterzens.command.profession.list": "NPC%s有以下可设置的职业,点击“X”可删除一个。", + "taterzens.profession.lacking": "NPC缺少%s职业。", + "taterzens.command.trait.add": "属性%s已成功添加。", + "taterzens.command.trait.remove": "属性%s已成功删除。", + "taterzens.command.trait.error.404": "未找到id为%s的属性。", + "taterzens.command.trait.list": "NPC%s有以下可设置的属性,点击“X”可删除一个。", + "taterzens.command.pose": "NPC的姿势已被设置为%s。", + "taterzens.command.respawn.toggle": "NPC的生成规则已被设置为%s。", + "taterzens.command.movement.set": "移动类型已被设置为%s。", + "taterzens.command.movement.follow.set": "NPC的跟随目标已被设置为%s。", + "taterzens.command.movement.follow.error.uuid": "跟随类型%s需要设置目标的UUID参数。", + "taterzens.command.entity_type.set": "NPC实体类型已被设置为%s。", + "taterzens.command.entity_type.reset": "实体类型%s已重置为默认值。", + "taterzens.command.behaviour.set": "行为方式已被设置为%s。", + "taterzens.command.behaviour.suggest.invulnerable.false": "点击此处可关闭NPC的无敌模式。", + "taterzens.command.skin.fetched": "NPC的皮肤已从%s中获取。", + "taterzens.command.skin.error": "无法从%s中获取皮肤。", + "taterzens.command.skin.mirrored": "NPC%s的皮肤已成功镜像。", + "taterzens.command.select": "你已选择%s。", + "taterzens.command.deselect": "你目前并没有选择任何NPC。", + "taterzens.command.create": "名为%s的NPC已成功生成。", + "taterzens.command.remove": "名为%s的NPC已成功删除。", + "taterzens.command.list": "NPC列表:", + "taterzens.command.lock.success": "名为%s的NPC已锁定。", + "taterzens.command.unlock.success": "名为%s的NPC已解锁。", + "taterzens.command.error.locked": "名为%s的NPC已被锁定,无法编辑。", + "taterzens.command.mount": "名为%s的NPC正在骑乘%s。", + "taterzens.command.umount": "名为%s的NPC目前没有骑乘任何生物。", + "taterzens.command.tags.changed": "Tag标签%s已被更改为%s。", + "taterzens.command.tags.hide_name_hint.desc.1": "NPC的名称已被设置为%s,姿势被设置为%s,以确保可以隐藏其名称。", + "taterzens.command.tags.hide_name_hint.desc.2": "如果想保留NPC的名称,请将%s添加到自定义的团队里,然后更改其在团队中的位置。", + "taterzens.command.config.success": "已成功重载配置文件。", + "taterzens.command.rename.success": "已成功将NPC的名称重命名为%s。", + "taterzens.command.language.success": "已成功获取语言文件并将语言切换至%s。", + "taterzens.command.language.server_translations_hint.1": "你目前使用的是来自服务器的语言模组,不会产生任何影响。", + "taterzens.command.language.server_translations_hint.2": "除非更改客户端的语言。", + "taterzens.command.language.error": "尝试获取语言文件%s时发生了错误。", + "taterzens.command.language.404": "语言文件%s不可用,你愿意帮助翻译吗?如果想的话请访问%s获取更多信息。", + "taterzens.command.wiki": "访问%s文档。", + "taterzens.command.sounds.404": "声音材质包%s在NPC的%s中的声音是不可用的。", + "taterzens.command.sounds.ambient": "环境", + "taterzens.command.sounds.hurt": "受伤", + "taterzens.command.sounds.death": "死亡", + "taterzens.command.sounds.invalid": "无效的声音路径。", + "taterzens.command.sounds.list.ambient": "目前设置的环境声音:", + "taterzens.command.sounds.list.hurt": "目前设置的受伤声音:", + "taterzens.command.sounds.list.death": "目前设置的死亡声音:", + "taterzens.command.sounds.list.empty": "未设置任何声音。", + "taterzens.command.sounds.add.success": "声音%s已成功添加。", + "taterzens.command.sounds.add.failure": "声音%s添加失败。", + "taterzens.command.sounds.remove.success": "声音%s已成功删除。", + "taterzens.command.sounds.remove.failure": "声音%s无法被删除。", + "taterzens.command.sounds.remove.outofbounds": "无法删除索引为%s的声音,最低索引为%s,最高索引为%s。", + "taterzens.command.sounds.remove.all.success": "所有%s的声音已成功被删除。", + "taterzens.command.sounds.remove.all.failure": "无法删除所有%s声音。", + "taterzens.gui.forge": "本模组的Forge版本不支持GUI,请安装本模组的Fabric版本。", + "taterzens.npc.interact.cooldown": "你需要等待%s秒后才能再次与我互动。", + "taterzens.tooltip.current_editor": "正在编辑:%s。", + "taterzens.tooltip.see_docs": "前往查看文档", + "taterzens.tooltip.see_uuid": "查看UUID", + "taterzens.tooltip.new_selection": "选择%s。", + "taterzens.tooltip.current_selection": "目前已选择:%s.", + "taterzens.tooltip.delete": "删除%s。", + "taterzens.tooltip.edit": "编辑%s。", + "taterzens.tooltip.disable_invulnerability": "关闭无敌", + "taterzens.tooltip.exit": "退出", + "taterzens.error.invalid.url": "URL%s是无效的。", + "taterzens.error.invalid.text": "你输入的NBT文本是无效的。", + "taterzens.error.404.detected": "在你面前未检测到NPC。", + "taterzens.error.404.id": "未找到id为%s的NPC。", + "taterzens.error.404.name": "未找到名称为%s的NPC。", + "taterzens.error.404.uuid": "未找到UUID为%s的NPC。", + "taterzens.error.multiple.name": "在你的附近存在多个名称为%s的NPC。", + "taterzens.error.select": "请先选择一名NPC!", + "taterzens.error.permission": "该操作要求的权限等级%s高于你目前的权限等级。", + "taterzens.error.enableBungee": "请在配置文件中开启支持bungee,否则其将无法生效。" } \ No newline at end of file diff --git a/common/src/main/resources/taterzens.accesswidener b/src/main/resources/taterzens.accesswidener similarity index 100% rename from common/src/main/resources/taterzens.accesswidener rename to src/main/resources/taterzens.accesswidener diff --git a/common/src/main/resources/taterzens.common.mixins.json b/src/main/resources/taterzens.common.mixins.json similarity index 85% rename from common/src/main/resources/taterzens.common.mixins.json rename to src/main/resources/taterzens.common.mixins.json index a2d76cc4e..4cbc9377e 100644 --- a/common/src/main/resources/taterzens.common.mixins.json +++ b/src/main/resources/taterzens.common.mixins.json @@ -1,7 +1,7 @@ { "required": true, "minVersion": "0.8", - "package": "org.samo_lego.taterzens.mixin", + "package": "org.samo_lego.taterzens.common.mixin", "compatibilityLevel": "JAVA_16", "mixins": [ "ChunkMapMixin_TaterzenList", @@ -16,7 +16,6 @@ "accessors.APlayer", "network.ServerGamePacketListenerImplMixin_BungeeListener", "network.ServerGamePacketListenerImplMixin_MsgEditor", - "network.ServerGamePacketListenerImplMixin_PacketFaker", "player.PlayerMixin_PeacefulDamage", "player.ServerPlayerMixinCast_ITaterzenEditor", "player.ServerPlayerMixinCast_ITaterzenPlayer" @@ -24,6 +23,5 @@ "client": [], "injectors": { "defaultRequire": 1 - }, - "refmap": "${refmap}" + } } diff --git a/fabric/src/main/resources/taterzens.mixins.json b/src/main/resources/taterzens.mixins.json similarity index 85% rename from fabric/src/main/resources/taterzens.mixins.json rename to src/main/resources/taterzens.mixins.json index 5888b27ef..829efe97c 100644 --- a/fabric/src/main/resources/taterzens.mixins.json +++ b/src/main/resources/taterzens.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "org.samo_lego.taterzens.fabric.mixin", - "compatibilityLevel": "JAVA_16", + "compatibilityLevel": "JAVA_17", "mixins": [ "AMappedRegistry" ], diff --git a/common/src/main/resources/assets/taterzens/en_us.json b/src/main/resources/taterzens/en_us.json similarity index 100% rename from common/src/main/resources/assets/taterzens/en_us.json rename to src/main/resources/taterzens/en_us.json diff --git a/common/src/main/resources/assets/taterzens/sl_si.json b/src/main/resources/taterzens/sl_si.json similarity index 100% rename from common/src/main/resources/assets/taterzens/sl_si.json rename to src/main/resources/taterzens/sl_si.json diff --git a/common/src/main/resources/taterzens_icon.png b/src/main/resources/taterzens_icon.png similarity index 100% rename from common/src/main/resources/taterzens_icon.png rename to src/main/resources/taterzens_icon.png