diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 25a4b9d..8d37231 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: matrix: # Use these Java versions java: [ - 17 + 21 ] # and run on both Linux and Windows os: [ubuntu-20.04, windows-latest] diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8e44eaf..d6a3f2e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,11 +8,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: set up JDK 17 + - name: set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'adopt-hotspot' - java-version: 17 + java-version: 21 cache: 'gradle' - name: make gradle wrapper executable diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f49140..4339063 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,4 +3,4 @@ ### Fixed: - ### Changed: -- Updated to mc 1.20.1 \ No newline at end of file +- Updated to mc 1.21 \ No newline at end of file diff --git a/build.gradle b/build.gradle index 074df79..8fe2c71 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.3-SNAPSHOT' + id 'fabric-loom' version '1.6-SNAPSHOT' id 'maven-publish' } @@ -46,14 +46,14 @@ processResources { } tasks.withType(JavaCompile).configureEach { - it.options.release = 17 + it.options.release = 21 } java { withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } jar { diff --git a/gradle.properties b/gradle.properties index 3f53b07..559ffc2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.20.1 - yarn_mappings=1.20.1+build.10 - loader_version=0.14.21 + minecraft_version=1.21 + yarn_mappings=1.21+build.2 + loader_version=0.15.11 # Mod Properties mod_version = 1.1.4 @@ -14,6 +14,6 @@ org.gradle.jvmargs=-Xmx1G # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.86.0+1.20.1 - cloth_config_version=11.0.99 - mod_menu_version=7.0.0 + fabric_version=0.100.3+1.21 + cloth_config_version=15.0.127 + mod_menu_version=11.0.0 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..e644113 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 fae0804..b82aa23 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +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.7-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..1aa94a4 100644 --- a/gradlew +++ b/gradlew @@ -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 107acd3..25da30d 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,13 +41,13 @@ 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. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -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/jitpack.yml b/jitpack.yml index 80847d7..f84ce2a 100644 --- a/jitpack.yml +++ b/jitpack.yml @@ -1,5 +1,5 @@ jdk: - - openjdk17 + - openjdk21 before_install: - - sdk install java 17.0.3-tem - - sdk use java 17.0.3-tem + - sdk install java 21.0.0-tem + - sdk use java 21.0.0-tem diff --git a/src/main/java/net/dragonloot/DragonLootClient.java b/src/main/java/net/dragonloot/DragonLootClient.java index 5075037..cf07f37 100644 --- a/src/main/java/net/dragonloot/DragonLootClient.java +++ b/src/main/java/net/dragonloot/DragonLootClient.java @@ -14,7 +14,7 @@ public class DragonLootClient implements ClientModInitializer { public void onInitializeClient() { RenderInit.init(); ModelProviderInit.init(); - NetworkInit.init(); + NetworkInit.clientInit(); } } diff --git a/src/main/java/net/dragonloot/DragonLootMain.java b/src/main/java/net/dragonloot/DragonLootMain.java index 6f77d5d..a26f73d 100644 --- a/src/main/java/net/dragonloot/DragonLootMain.java +++ b/src/main/java/net/dragonloot/DragonLootMain.java @@ -7,7 +7,7 @@ public class DragonLootMain implements ModInitializer { public static Identifier ID(String path) { - return new Identifier(MOD_ID, path); + return Identifier.of(MOD_ID, path); } private static final String MOD_ID = "dragonloot"; @@ -19,6 +19,7 @@ public void onInitialize() { EntityInit.init(); ItemInit.init(); TagInit.init(); + NetworkInit.serverInit(); } } diff --git a/src/main/java/net/dragonloot/compat/recipes/CompatRecipes.java b/src/main/java/net/dragonloot/compat/recipes/CompatRecipes.java index 9c1b3e9..0cf1a60 100644 --- a/src/main/java/net/dragonloot/compat/recipes/CompatRecipes.java +++ b/src/main/java/net/dragonloot/compat/recipes/CompatRecipes.java @@ -6,22 +6,22 @@ public class CompatRecipes { - private static final Identifier NETHERITE_UPGRADE_TEMPLATE = new Identifier("minecraft:netherite_upgrade_smithing_template"); + private static final Identifier NETHERITE_UPGRADE_TEMPLATE = Identifier.of("minecraft:netherite_upgrade_smithing_template"); public static void loadRecipes() { if (FabricLoader.getInstance().isModLoaded("netherite_plus")) { - RecipeGenerator.SMITHING_RECIPES.put("dragon_horse_armor", new RecipeMaterial(new Identifier("netherite_plus", "netherite_horse_armor"), DragonLootMain.ID("dragon_scale"), "item", "item", DragonLootMain.ID("dragon_horse_armor"), NETHERITE_UPGRADE_TEMPLATE)); - RecipeGenerator.SMITHING_RECIPES.put("dragon_trident", new RecipeMaterial(new Identifier("netherite_plus", "netherite_trident"), DragonLootMain.ID("dragon_scale"), "item", "item", DragonLootMain.ID("dragon_trident"), NETHERITE_UPGRADE_TEMPLATE)); - RecipeGenerator.SMITHING_RECIPES.put("dragon_bow", new RecipeMaterial(new Identifier("netherite_plus", "netherite_bow"), DragonLootMain.ID("dragon_scale"), "item", "item", DragonLootMain.ID("dragon_bow"), NETHERITE_UPGRADE_TEMPLATE)); - RecipeGenerator.SMITHING_RECIPES.put("dragon_crossbow", new RecipeMaterial(new Identifier("netherite_plus", "netherite_crossbow"), DragonLootMain.ID("dragon_scale"), "item", "item", DragonLootMain.ID("dragon_crossbow"), NETHERITE_UPGRADE_TEMPLATE)); - RecipeGenerator.SMITHING_RECIPES.put("upgraded_dragon_chestplate", new RecipeMaterial(new Identifier("dragonloot", "dragon_chestplate"), new Identifier("netherite_plus", "netherite_elytra"), "item", "item", DragonLootMain.ID("upgraded_dragon_chestplate"), NETHERITE_UPGRADE_TEMPLATE)); + RecipeGenerator.SMITHING_RECIPES.put("dragon_horse_armor", new RecipeMaterial(Identifier.of("netherite_plus", "netherite_horse_armor"), DragonLootMain.ID("dragon_scale"), "item", "item", DragonLootMain.ID("dragon_horse_armor"), NETHERITE_UPGRADE_TEMPLATE)); + RecipeGenerator.SMITHING_RECIPES.put("dragon_trident", new RecipeMaterial(Identifier.of("netherite_plus", "netherite_trident"), DragonLootMain.ID("dragon_scale"), "item", "item", DragonLootMain.ID("dragon_trident"), NETHERITE_UPGRADE_TEMPLATE)); + RecipeGenerator.SMITHING_RECIPES.put("dragon_bow", new RecipeMaterial(Identifier.of("netherite_plus", "netherite_bow"), DragonLootMain.ID("dragon_scale"), "item", "item", DragonLootMain.ID("dragon_bow"), NETHERITE_UPGRADE_TEMPLATE)); + RecipeGenerator.SMITHING_RECIPES.put("dragon_crossbow", new RecipeMaterial(Identifier.of("netherite_plus", "netherite_crossbow"), DragonLootMain.ID("dragon_scale"), "item", "item", DragonLootMain.ID("dragon_crossbow"), NETHERITE_UPGRADE_TEMPLATE)); + RecipeGenerator.SMITHING_RECIPES.put("upgraded_dragon_chestplate", new RecipeMaterial(Identifier.of("dragonloot", "dragon_chestplate"), Identifier.of("netherite_plus", "netherite_elytra"), "item", "item", DragonLootMain.ID("upgraded_dragon_chestplate"), NETHERITE_UPGRADE_TEMPLATE)); } else { - RecipeGenerator.SMITHING_RECIPES.put("dragon_horse_armor", new RecipeMaterial(new Identifier("minecraft", "diamond_horse_armor"), DragonLootMain.ID("dragon_scale"), "item", "item", DragonLootMain.ID("dragon_horse_armor"), NETHERITE_UPGRADE_TEMPLATE)); - RecipeGenerator.SMITHING_RECIPES.put("dragon_trident", new RecipeMaterial(new Identifier("minecraft", "trident"), DragonLootMain.ID("dragon_scale"), "item", "item", DragonLootMain.ID("dragon_trident"), NETHERITE_UPGRADE_TEMPLATE)); - RecipeGenerator.SMITHING_RECIPES.put("dragon_bow", new RecipeMaterial(new Identifier("minecraft", "bow"), DragonLootMain.ID("dragon_scale"), "item", "item", DragonLootMain.ID("dragon_bow"), NETHERITE_UPGRADE_TEMPLATE)); - RecipeGenerator.SMITHING_RECIPES.put("dragon_crossbow", new RecipeMaterial(new Identifier("minecraft", "crossbow"), DragonLootMain.ID("dragon_scale"), "item", "item", DragonLootMain.ID("dragon_crossbow"), NETHERITE_UPGRADE_TEMPLATE)); - RecipeGenerator.SMITHING_RECIPES.put("upgraded_dragon_chestplate", new RecipeMaterial(new Identifier("dragonloot", "dragon_chestplate"), new Identifier("minecraft", "elytra"), "item", "item", DragonLootMain.ID("upgraded_dragon_chestplate"), NETHERITE_UPGRADE_TEMPLATE)); + RecipeGenerator.SMITHING_RECIPES.put("dragon_horse_armor", new RecipeMaterial(Identifier.of("minecraft", "diamond_horse_armor"), DragonLootMain.ID("dragon_scale"), "item", "item", DragonLootMain.ID("dragon_horse_armor"), NETHERITE_UPGRADE_TEMPLATE)); + RecipeGenerator.SMITHING_RECIPES.put("dragon_trident", new RecipeMaterial(Identifier.of("minecraft", "trident"), DragonLootMain.ID("dragon_scale"), "item", "item", DragonLootMain.ID("dragon_trident"), NETHERITE_UPGRADE_TEMPLATE)); + RecipeGenerator.SMITHING_RECIPES.put("dragon_bow", new RecipeMaterial(Identifier.of("minecraft", "bow"), DragonLootMain.ID("dragon_scale"), "item", "item", DragonLootMain.ID("dragon_bow"), NETHERITE_UPGRADE_TEMPLATE)); + RecipeGenerator.SMITHING_RECIPES.put("dragon_crossbow", new RecipeMaterial(Identifier.of("minecraft", "crossbow"), DragonLootMain.ID("dragon_scale"), "item", "item", DragonLootMain.ID("dragon_crossbow"), NETHERITE_UPGRADE_TEMPLATE)); + RecipeGenerator.SMITHING_RECIPES.put("upgraded_dragon_chestplate", new RecipeMaterial(Identifier.of("dragonloot", "dragon_chestplate"), Identifier.of("minecraft", "elytra"), "item", "item", DragonLootMain.ID("upgraded_dragon_chestplate"), NETHERITE_UPGRADE_TEMPLATE)); } diff --git a/src/main/java/net/dragonloot/compat/recipes/RecipeGenerator.java b/src/main/java/net/dragonloot/compat/recipes/RecipeGenerator.java index fbbd457..4bec1e4 100644 --- a/src/main/java/net/dragonloot/compat/recipes/RecipeGenerator.java +++ b/src/main/java/net/dragonloot/compat/recipes/RecipeGenerator.java @@ -25,7 +25,7 @@ public static JsonObject generateJson(Identifier base, Identifier addition, Stri json.add("addition", obj); obj = new JsonObject(); - obj.addProperty("item", output.toString()); + obj.addProperty("id", output.toString()); json.add("result", obj); obj = new JsonObject(); diff --git a/src/main/java/net/dragonloot/config/DragonLootConfig.java b/src/main/java/net/dragonloot/config/DragonLootConfig.java index 85e48e1..1f2d220 100644 --- a/src/main/java/net/dragonloot/config/DragonLootConfig.java +++ b/src/main/java/net/dragonloot/config/DragonLootConfig.java @@ -38,6 +38,8 @@ public class DragonLootConfig implements ConfigData { @ConfigEntry.Gui.RequiresRestart public float dragon_item_base_damage = 5F; @ConfigEntry.Gui.RequiresRestart + public float dragon_item_mining_speed_multiplier = 12F; + @ConfigEntry.Gui.RequiresRestart public int dragon_tool_enchantability = 20; @ConfigEntry.Gui.RequiresRestart public boolean dragon_anvil_no_cap = true; diff --git a/src/main/java/net/dragonloot/entity/DragonTridentEntity.java b/src/main/java/net/dragonloot/entity/DragonTridentEntity.java index 15a46cc..a92d367 100644 --- a/src/main/java/net/dragonloot/entity/DragonTridentEntity.java +++ b/src/main/java/net/dragonloot/entity/DragonTridentEntity.java @@ -8,7 +8,6 @@ import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; -import net.minecraft.entity.LightningEntity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.data.DataTracker; @@ -23,7 +22,7 @@ import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; import net.minecraft.util.hit.EntityHitResult; -import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; @@ -37,28 +36,25 @@ public class DragonTridentEntity extends PersistentProjectileEntity { public DragonTridentEntity(EntityType entityType, World world) { super(entityType, world); - this.tridentStack = new ItemStack(ItemInit.DRAGON_TRIDENT_ITEM); } public DragonTridentEntity(World world, LivingEntity owner, ItemStack stack) { - super(EntityInit.DRAGONTRIDENT_ENTITY, owner, world); - this.tridentStack = new ItemStack(ItemInit.DRAGON_TRIDENT_ITEM); - this.tridentStack = stack.copy(); - this.dataTracker.set(LOYALTY, (byte) EnchantmentHelper.getLoyalty(stack)); + super(EntityInit.DRAGON_TRIDENT_ENTITY, owner, world, stack, null); + this.dataTracker.set(LOYALTY, this.getLoyalty(stack)); this.dataTracker.set(ENCHANTED, stack.hasGlint()); } - @Environment(EnvType.CLIENT) - public DragonTridentEntity(World world, double x, double y, double z) { - super(EntityInit.DRAGONTRIDENT_ENTITY, x, y, z, world); - this.tridentStack = new ItemStack(ItemInit.DRAGON_TRIDENT_ITEM); + public DragonTridentEntity(World world, double x, double y, double z, ItemStack stack) { + super(EntityInit.DRAGON_TRIDENT_ENTITY, x, y, z, world, stack, stack); + this.dataTracker.set(LOYALTY, this.getLoyalty(stack)); + this.dataTracker.set(ENCHANTED, stack.hasGlint()); } @Override - protected void initDataTracker() { - super.initDataTracker(); - this.dataTracker.startTracking(LOYALTY, (byte) 0); - this.dataTracker.startTracking(ENCHANTED, false); + protected void initDataTracker(DataTracker.Builder builder) { + super.initDataTracker(builder); + builder.add(LOYALTY, (byte) 0); + builder.add(ENCHANTED, false); } @Override @@ -125,48 +121,30 @@ protected EntityHitResult getEntityCollision(Vec3d currentPosition, Vec3d nextPo @Override protected void onEntityHit(EntityHitResult entityHitResult) { Entity entity = entityHitResult.getEntity(); - float f = 8.0F; - if (entity instanceof LivingEntity) { - LivingEntity livingEntity = (LivingEntity) entity; - f += EnchantmentHelper.getAttackDamage(this.tridentStack, livingEntity.getGroup()); - } - + float f = 8.0f; Entity entity2 = this.getOwner(); - World world = entity.getWorld(); - DamageSource damageSource = world.getDamageSources().trident(this, (Entity) (entity2 == null ? this : entity2)); + DamageSource damageSource = this.getDamageSources().trident(this, entity2 == null ? this : entity2); + World world = this.getWorld(); + if (world instanceof ServerWorld serverWorld) { + f = EnchantmentHelper.getDamage(serverWorld, this.getWeaponStack(), entity, damageSource, f); + } this.dealtDamage = true; - SoundEvent soundEvent = SoundEvents.ITEM_TRIDENT_HIT; if (entity.damage(damageSource, f)) { if (entity.getType() == EntityType.ENDERMAN) { return; } - - if (entity instanceof LivingEntity) { - LivingEntity livingEntity2 = (LivingEntity) entity; - if (entity2 instanceof LivingEntity) { - EnchantmentHelper.onUserDamaged(livingEntity2, entity2); - EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity2); - } - - this.onHit(livingEntity2); + world = this.getWorld(); + if (world instanceof ServerWorld serverWorld) { + EnchantmentHelper.onTargetDamaged(serverWorld, entity, damageSource, this.getWeaponStack()); } - } - - this.setVelocity(this.getVelocity().multiply(-0.01D, -0.1D, -0.01D)); - float g = 1.0F; - if (this.getWorld() instanceof ServerWorld && this.getWorld().isThundering() && EnchantmentHelper.hasChanneling(this.tridentStack)) { - BlockPos blockPos = entity.getBlockPos(); - if (this.getWorld().isSkyVisible(blockPos)) { - LightningEntity lightningEntity = (LightningEntity) EntityType.LIGHTNING_BOLT.create(this.getWorld()); - lightningEntity.refreshPositionAfterTeleport(Vec3d.ofBottomCenter(blockPos)); - lightningEntity.setChanneler(entity2 instanceof ServerPlayerEntity ? (ServerPlayerEntity) entity2 : null); - this.getWorld().spawnEntity(lightningEntity); - soundEvent = SoundEvents.ITEM_TRIDENT_THUNDER; - g = 5.0F; + if (entity instanceof LivingEntity) { + LivingEntity livingEntity = (LivingEntity) entity; + this.knockback(livingEntity, damageSource); + this.onHit(livingEntity); } } - - this.playSound(soundEvent, g, 1.0F); + this.setVelocity(this.getVelocity().multiply(-0.01, -0.1, -0.01)); + this.playSound(SoundEvents.ITEM_TRIDENT_HIT, 1.0f, 1.0f); } @Override @@ -185,18 +163,13 @@ public void onPlayerCollision(PlayerEntity player) { @Override public void readCustomDataFromNbt(NbtCompound tag) { super.readCustomDataFromNbt(tag); - if (tag.contains("Dragon_Trident", 10)) { - this.tridentStack = ItemStack.fromNbt(tag.getCompound("Dragon_Trident")); - } - this.dealtDamage = tag.getBoolean("DealtDamage"); - this.dataTracker.set(LOYALTY, (byte) EnchantmentHelper.getLoyalty(this.tridentStack)); + this.dataTracker.set(LOYALTY, this.getLoyalty(this.getItemStack())); } @Override public void writeCustomDataToNbt(NbtCompound tag) { super.writeCustomDataToNbt(tag); - tag.put("Dragon_Trident", this.tridentStack.writeNbt(new NbtCompound())); tag.putBoolean("DealtDamage", this.dealtDamage); } @@ -220,8 +193,22 @@ public boolean shouldRender(double cameraX, double cameraY, double cameraZ) { return true; } + @Override + protected ItemStack getDefaultItemStack() { + return new ItemStack(ItemInit.DRAGON_TRIDENT); + } + + private byte getLoyalty(ItemStack stack) { + World world = this.getWorld(); + if (world instanceof ServerWorld serverWorld) { + return (byte) MathHelper.clamp(EnchantmentHelper.getTridentReturnAcceleration(serverWorld, stack, this), 0, 127); + } + return 0; + } + static { LOYALTY = DataTracker.registerData(DragonTridentEntity.class, TrackedDataHandlerRegistry.BYTE); ENCHANTED = DataTracker.registerData(DragonTridentEntity.class, TrackedDataHandlerRegistry.BOOLEAN); } + } diff --git a/src/main/java/net/dragonloot/entity/model/DragonHelmetModel.java b/src/main/java/net/dragonloot/entity/model/DragonHelmetModel.java index 2580060..992e541 100644 --- a/src/main/java/net/dragonloot/entity/model/DragonHelmetModel.java +++ b/src/main/java/net/dragonloot/entity/model/DragonHelmetModel.java @@ -31,10 +31,11 @@ public static TexturedModelData getTexturedModelData() { } @Override - public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) { + public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, int color) { this.HornLU.pitch = 0.7854F; this.HornRD.yaw = 0.3927F; this.HornLD.yaw = -0.3927F; - this.root.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha); + this.root.render(matrices, vertexConsumer, light, overlay, color); } + } diff --git a/src/main/java/net/dragonloot/entity/render/DragonTridentEntityRenderer.java b/src/main/java/net/dragonloot/entity/render/DragonTridentEntityRenderer.java index 0f04dd2..cf1e37d 100644 --- a/src/main/java/net/dragonloot/entity/render/DragonTridentEntityRenderer.java +++ b/src/main/java/net/dragonloot/entity/render/DragonTridentEntityRenderer.java @@ -31,7 +31,7 @@ public void render(DragonTridentEntity tridentEntity, float f, float g, MatrixSt matrixStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(MathHelper.lerp(g, tridentEntity.prevYaw, tridentEntity.getYaw()) - 90.0F)); matrixStack.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(MathHelper.lerp(g, tridentEntity.prevPitch, tridentEntity.getPitch()) + 90.0F)); VertexConsumer vertexConsumer = ItemRenderer.getDirectItemGlintConsumer(vertexConsumerProvider, this.model.getLayer(this.getTexture(tridentEntity)), false, tridentEntity.isEnchanted()); - this.model.render(matrixStack, vertexConsumer, i, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F); + this.model.render(matrixStack, vertexConsumer, i, OverlayTexture.DEFAULT_UV); matrixStack.pop(); super.render(tridentEntity, f, g, matrixStack, vertexConsumerProvider, i); } diff --git a/src/main/java/net/dragonloot/init/BlockInit.java b/src/main/java/net/dragonloot/init/BlockInit.java index bf9cefa..c9debcc 100644 --- a/src/main/java/net/dragonloot/init/BlockInit.java +++ b/src/main/java/net/dragonloot/init/BlockInit.java @@ -1,7 +1,7 @@ package net.dragonloot.init; import net.dragonloot.block.*; -import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.minecraft.block.AbstractBlock; import net.minecraft.block.Blocks; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; @@ -11,11 +11,11 @@ public class BlockInit { - public static final DragonAnvilBlock DRAGON_ANVIL_BLOCK = new DragonAnvilBlock(FabricBlockSettings.copy(Blocks.ANVIL)); + public static final DragonAnvilBlock DRAGON_ANVIL_BLOCK = new DragonAnvilBlock(AbstractBlock.Settings.copy(Blocks.ANVIL)); public static void init() { - Registry.register(Registries.ITEM, new Identifier("dragonloot", "dragon_anvil"), new BlockItem(DRAGON_ANVIL_BLOCK, new Item.Settings())); - Registry.register(Registries.BLOCK, new Identifier("dragonloot", "dragon_anvil"), DRAGON_ANVIL_BLOCK); + Registry.register(Registries.ITEM, Identifier.of("dragonloot", "dragon_anvil"), new BlockItem(DRAGON_ANVIL_BLOCK, new Item.Settings())); + Registry.register(Registries.BLOCK, Identifier.of("dragonloot", "dragon_anvil"), DRAGON_ANVIL_BLOCK); } } diff --git a/src/main/java/net/dragonloot/init/EntityInit.java b/src/main/java/net/dragonloot/init/EntityInit.java index efcb674..db79aa3 100644 --- a/src/main/java/net/dragonloot/init/EntityInit.java +++ b/src/main/java/net/dragonloot/init/EntityInit.java @@ -1,8 +1,6 @@ package net.dragonloot.init; import net.dragonloot.entity.DragonTridentEntity; -import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder; -import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnGroup; import net.minecraft.registry.Registries; @@ -11,10 +9,10 @@ public class EntityInit { - public static final EntityType DRAGONTRIDENT_ENTITY = FabricEntityTypeBuilder.create(SpawnGroup.MISC, DragonTridentEntity::new).dimensions(EntityDimensions.fixed(0.5F, 0.5F)).build(); + public static final EntityType DRAGON_TRIDENT_ENTITY = EntityType.Builder.create(DragonTridentEntity::new, SpawnGroup.MISC).dimensions(0.5F, 0.5F).eyeHeight(0.13f).maxTrackingRange(4).trackingTickInterval(20).build(); public static void init() { - Registry.register(Registries.ENTITY_TYPE, new Identifier("dragonloot", "dragon_trident"), DRAGONTRIDENT_ENTITY); + Registry.register(Registries.ENTITY_TYPE, Identifier.of("dragonloot", "dragon_trident"), DRAGON_TRIDENT_ENTITY); } } diff --git a/src/main/java/net/dragonloot/init/ItemInit.java b/src/main/java/net/dragonloot/init/ItemInit.java index 436205b..caf6fa4 100644 --- a/src/main/java/net/dragonloot/init/ItemInit.java +++ b/src/main/java/net/dragonloot/init/ItemInit.java @@ -6,6 +6,7 @@ import net.dragonloot.item.*; import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; +import net.minecraft.component.DataComponentTypes; import net.minecraft.item.*; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; @@ -13,34 +14,33 @@ import net.minecraft.registry.RegistryKeys; import net.minecraft.text.Text; import net.minecraft.util.Identifier; +import net.minecraft.util.Rarity; public class ItemInit { public static final RegistryKey DRAGON_ITEM_GROUP = RegistryKey.of(RegistryKeys.ITEM_GROUP, DragonLootMain.ID("dragonloot")); // Items - public static final Item DRAGON_SCALE_ITEM = register("dragon_scale", new DragonScaleItem(new Item.Settings().fireproof())); - public static final Item DRAGON_HORSE_ARMOR_ITEM = register("dragon_horse_armor", new HorseArmorItem(18, "dragon", new Item.Settings().maxCount(1).fireproof())); - // Armor - public static final ArmorMaterial DRAGON_ARMOR_MATERIAL = DragonArmorMaterial.getInstance(); - - public static final Item DRAGON_HELMET = register("dragon_helmet", new DragonArmor(DRAGON_ARMOR_MATERIAL, ArmorItem.Type.HELMET, new Item.Settings().fireproof())); - public static final Item DRAGON_CHESTPLATE = register("dragon_chestplate", new DragonArmor(DRAGON_ARMOR_MATERIAL, ArmorItem.Type.CHESTPLATE, new Item.Settings().fireproof())); - public static final Item DRAGON_LEGGINGS = register("dragon_leggings", new DragonArmor(DRAGON_ARMOR_MATERIAL, ArmorItem.Type.LEGGINGS, new Item.Settings().fireproof())); - public static final Item DRAGON_BOOTS = register("dragon_boots", new DragonArmor(DRAGON_ARMOR_MATERIAL, ArmorItem.Type.BOOTS, new Item.Settings().fireproof())); - public static final Item UPGRADED_DRAGON_CHESTPLATE = register("upgraded_dragon_chestplate", new DragonArmor(DRAGON_ARMOR_MATERIAL, ArmorItem.Type.CHESTPLATE, new Item.Settings().fireproof())); - - // Tools - public static final Item DRAGON_PICKAXE_ITEM = register("dragon_pickaxe", new DragonPickaxeItem(DragonToolMaterial.getInstance(), 1, -2.8f, new Item.Settings().fireproof())); - public static final Item DRAGON_AXE_ITEM = register("dragon_axe", new DragonAxeItem(DragonToolMaterial.getInstance(), 5, -3f, new Item.Settings().fireproof())); - public static final Item DRAGON_SHOVEL_ITEM = register("dragon_shovel", new DragonShovelItem(DragonToolMaterial.getInstance(), 1.5f, -3f, new Item.Settings().fireproof())); - public static final Item DRAGON_HOE_ITEM = register("dragon_hoe", new DragonHoeItem(DragonToolMaterial.getInstance(), -4, -2f, new Item.Settings().fireproof())); - - // Weapons - public static final Item DRAGON_SWORD_ITEM = register("dragon_sword", new DragonSwordItem(DragonToolMaterial.getInstance(), 3, -2.4f, new Item.Settings().fireproof())); - public static final Item DRAGON_BOW_ITEM = register("dragon_bow", new DragonBowItem(new Item.Settings().fireproof().maxDamage(DragonToolMaterial.getInstance().getDurability()))); - public static final Item DRAGON_CROSSBOW_ITEM = register("dragon_crossbow", new DragonCrossbowItem(new Item.Settings().fireproof().maxDamage(DragonToolMaterial.getInstance().getDurability()))); - public static final Item DRAGON_TRIDENT_ITEM = register("dragon_trident", new DragonTridentItem(new Item.Settings().maxDamage(DragonToolMaterial.getInstance().getDurability()).fireproof())); + public static final Item DRAGON_SCALE = register("dragon_scale", new Item(new Item.Settings().fireproof())); + public static final Item DRAGON_HORSE_ARMOR = register("dragon_horse_armor", new AnimalArmorItem(DragonArmorMaterials.DRAGON, AnimalArmorItem.Type.EQUESTRIAN, false, new Item.Settings().maxCount(1).fireproof())); + + public static final Item UPGRADED_DRAGON_CHESTPLATE = register("upgraded_dragon_chestplate", new ArmorItem(DragonArmorMaterials.DRAGON, ArmorItem.Type.CHESTPLATE, new Item.Settings().maxDamage(ArmorItem.Type.CHESTPLATE.getMaxDamage(ConfigInit.CONFIG.dragon_armor_durability_multiplier)).fireproof())); + + public static final Item DRAGON_HELMET = register("dragon_helmet", new ArmorItem(DragonArmorMaterials.DRAGON, ArmorItem.Type.HELMET, new Item.Settings().maxDamage(ArmorItem.Type.HELMET.getMaxDamage(ConfigInit.CONFIG.dragon_armor_durability_multiplier)).fireproof())); + public static final Item DRAGON_CHESTPLATE = register("dragon_chestplate", new ArmorItem(DragonArmorMaterials.DRAGON, ArmorItem.Type.CHESTPLATE, new Item.Settings().maxDamage(ArmorItem.Type.CHESTPLATE.getMaxDamage(ConfigInit.CONFIG.dragon_armor_durability_multiplier)).fireproof())); + public static final Item DRAGON_LEGGINGS = register("dragon_leggings", new ArmorItem(DragonArmorMaterials.DRAGON, ArmorItem.Type.LEGGINGS, new Item.Settings().maxDamage(ArmorItem.Type.LEGGINGS.getMaxDamage(ConfigInit.CONFIG.dragon_armor_durability_multiplier)).fireproof())); + public static final Item DRAGON_BOOTS = register("dragon_boots", new ArmorItem(DragonArmorMaterials.DRAGON, ArmorItem.Type.BOOTS, new Item.Settings().maxDamage(ArmorItem.Type.BOOTS.getMaxDamage(ConfigInit.CONFIG.dragon_armor_durability_multiplier)).fireproof())); + + public static final Item DRAGON_SWORD = register("dragon_sword", new SwordItem(DragonToolMaterials.DRAGON, new Item.Settings().attributeModifiers(SwordItem.createAttributeModifiers(DragonToolMaterials.DRAGON, 3, -2.4f)).fireproof())); + public static final Item DRAGON_SHOVEL = register("dragon_shovel", new ShovelItem(DragonToolMaterials.DRAGON, new Item.Settings().attributeModifiers(ShovelItem.createAttributeModifiers(DragonToolMaterials.DRAGON, 1.5f, -3.0f)).fireproof())); + public static final Item DRAGON_PICKAXE = register("dragon_pickaxe", new PickaxeItem(DragonToolMaterials.DRAGON, new Item.Settings().attributeModifiers(PickaxeItem.createAttributeModifiers(DragonToolMaterials.DRAGON, 1.0f, -2.8f)).fireproof())); + public static final Item DRAGON_AXE = register("dragon_axe", new AxeItem(DragonToolMaterials.DRAGON, new Item.Settings().attributeModifiers(AxeItem.createAttributeModifiers(DragonToolMaterials.DRAGON, 5.0f, -3.0f)).fireproof())); + public static final Item DRAGON_HOE = register("dragon_hoe", new HoeItem(DragonToolMaterials.DRAGON, new Item.Settings().attributeModifiers(HoeItem.createAttributeModifiers(DragonToolMaterials.DRAGON, -4f, -2.0f)).fireproof())); + + public static final Item DRAGON_BOW = register("dragon_bow", new BowItem(new Item.Settings().fireproof().maxDamage(DragonToolMaterials.DRAGON.getDurability()))); + public static final Item DRAGON_CROSSBOW = register("dragon_crossbow", new CrossbowItem(new Item.Settings().fireproof().maxDamage(DragonToolMaterials.DRAGON.getDurability()))); + + public static final Item DRAGON_TRIDENT = register("dragon_trident", new DragonTridentItem(new Item.Settings().rarity(Rarity.EPIC).maxDamage(DragonToolMaterials.DRAGON.getDurability()).attributeModifiers(TridentItem.createAttributeModifiers()).component(DataComponentTypes.TOOL, TridentItem.createToolComponent()).fireproof())); private static Item register(String id, Item item) { return register(DragonLootMain.ID(id), item); @@ -52,7 +52,7 @@ private static Item register(Identifier id, Item item) { } public static void init() { - Registry.register(Registries.ITEM_GROUP, DRAGON_ITEM_GROUP, FabricItemGroup.builder().entries((context, entries) -> entries.add(BlockInit.DRAGON_ANVIL_BLOCK)).icon(() -> new ItemStack(ItemInit.DRAGON_SCALE_ITEM)).displayName(Text.translatable("itemGroup.dragonloot.dragonloot")).build()); + Registry.register(Registries.ITEM_GROUP, DRAGON_ITEM_GROUP, FabricItemGroup.builder().entries((context, entries) -> entries.add(BlockInit.DRAGON_ANVIL_BLOCK)).icon(() -> new ItemStack(ItemInit.DRAGON_SCALE)).displayName(Text.translatable("itemGroup.dragonloot.dragonloot")).build()); CompatRecipes.loadRecipes(); RecipeGenerator.addRecipes(); diff --git a/src/main/java/net/dragonloot/init/ModelProviderInit.java b/src/main/java/net/dragonloot/init/ModelProviderInit.java index 619fe29..b0e21ed 100644 --- a/src/main/java/net/dragonloot/init/ModelProviderInit.java +++ b/src/main/java/net/dragonloot/init/ModelProviderInit.java @@ -1,6 +1,8 @@ package net.dragonloot.init; import net.minecraft.client.item.ModelPredicateProviderRegistry; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.ChargedProjectilesComponent; import net.minecraft.item.CrossbowItem; import net.minecraft.item.Items; import net.minecraft.util.Identifier; @@ -8,23 +10,27 @@ public class ModelProviderInit { public static void init() { - ModelPredicateProviderRegistry.register(ItemInit.DRAGON_BOW_ITEM, new Identifier("pull"), (stack, world, entity, seed) -> { + ModelPredicateProviderRegistry.register(ItemInit.DRAGON_BOW, Identifier.ofVanilla("pull"), (stack, world, entity, seed) -> { if (entity == null) { return 0.0F; } else { - return entity.getActiveItem() != stack ? 0.0F : (float) (stack.getMaxUseTime() - entity.getItemUseTimeLeft()) / 20.0F; + return entity.getActiveItem() != stack ? 0.0F : (float) (stack.getMaxUseTime(entity) - entity.getItemUseTimeLeft()) / 20.0F; } }); - ModelPredicateProviderRegistry.register(ItemInit.DRAGON_BOW_ITEM, new Identifier("pulling"), (itemStack, clientWorld, livingEntity, seed) -> livingEntity != null && livingEntity.isUsingItem() && livingEntity.getActiveItem() == itemStack ? 1.0F : 0.0F); - ModelPredicateProviderRegistry.register(ItemInit.DRAGON_CROSSBOW_ITEM, new Identifier("pull"), (itemStack, clientWorld, livingEntity, seed) -> { + ModelPredicateProviderRegistry.register(ItemInit.DRAGON_BOW, Identifier.ofVanilla("pulling"), (itemStack, clientWorld, livingEntity, seed) -> livingEntity != null && livingEntity.isUsingItem() && livingEntity.getActiveItem() == itemStack ? 1.0F : 0.0F); + ModelPredicateProviderRegistry.register(ItemInit.DRAGON_CROSSBOW, Identifier.ofVanilla("pull"), (itemStack, clientWorld, livingEntity, seed) -> { if (livingEntity == null) { return 0; } else - return CrossbowItem.isCharged(itemStack) ? 0.0F : (float) (itemStack.getMaxUseTime() - livingEntity.getItemUseTimeLeft()) / (float) CrossbowItem.getPullTime(itemStack); + return CrossbowItem.isCharged(itemStack) ? 0.0F : (float) (itemStack.getMaxUseTime(livingEntity) - livingEntity.getItemUseTimeLeft()) / (float) CrossbowItem.getPullTime(itemStack, livingEntity); }); - ModelPredicateProviderRegistry.register(ItemInit.DRAGON_CROSSBOW_ITEM, new Identifier("pulling"), (itemStack, clientWorld1, livingEntity, seed) -> livingEntity != null && livingEntity.isUsingItem() && livingEntity.getActiveItem() == itemStack && !CrossbowItem.isCharged(itemStack) ? 1.0F : 0.0F); - ModelPredicateProviderRegistry.register(ItemInit.DRAGON_CROSSBOW_ITEM, new Identifier("charged"), (itemStack, clientWorld, livingEntity, seed) -> livingEntity != null && CrossbowItem.isCharged(itemStack) ? 1.0F : 0.0F); - ModelPredicateProviderRegistry.register(ItemInit.DRAGON_CROSSBOW_ITEM, new Identifier("firework"), (itemStack, clientWorld, livingEntity, seed) -> livingEntity != null && CrossbowItem.isCharged(itemStack) && CrossbowItem.hasProjectile(itemStack, Items.FIREWORK_ROCKET) ? 1.0F : 0.0F); - ModelPredicateProviderRegistry.register(ItemInit.DRAGON_TRIDENT_ITEM, new Identifier("throwing"), (itemStack, clientWorld, livingEntity, seed) -> livingEntity != null && livingEntity.isUsingItem() && livingEntity.getActiveItem() == itemStack ? 1.0F : 0.0F); + ModelPredicateProviderRegistry.register(ItemInit.DRAGON_CROSSBOW, Identifier.ofVanilla("pulling"), (itemStack, clientWorld1, livingEntity, seed) -> livingEntity != null && livingEntity.isUsingItem() && livingEntity.getActiveItem() == itemStack && !CrossbowItem.isCharged(itemStack) ? 1.0F : 0.0F); + ModelPredicateProviderRegistry.register(ItemInit.DRAGON_CROSSBOW, Identifier.ofVanilla("charged"), (itemStack, clientWorld, livingEntity, seed) -> livingEntity != null && CrossbowItem.isCharged(itemStack) ? 1.0F : 0.0F); + ModelPredicateProviderRegistry.register(ItemInit.DRAGON_CROSSBOW, Identifier.ofVanilla("firework"), (stack, world, entity, seed) -> { + ChargedProjectilesComponent chargedProjectilesComponent = stack.get(DataComponentTypes.CHARGED_PROJECTILES); + return chargedProjectilesComponent != null && chargedProjectilesComponent.contains(Items.FIREWORK_ROCKET) ? 1.0f : 0.0f; + }); + + ModelPredicateProviderRegistry.register(ItemInit.DRAGON_TRIDENT, Identifier.ofVanilla("throwing"), (itemStack, clientWorld, livingEntity, seed) -> livingEntity != null && livingEntity.isUsingItem() && livingEntity.getActiveItem() == itemStack ? 1.0F : 0.0F); } } \ No newline at end of file diff --git a/src/main/java/net/dragonloot/init/NetworkInit.java b/src/main/java/net/dragonloot/init/NetworkInit.java index 4197cae..04c45a4 100644 --- a/src/main/java/net/dragonloot/init/NetworkInit.java +++ b/src/main/java/net/dragonloot/init/NetworkInit.java @@ -1,11 +1,16 @@ package net.dragonloot.init; -import net.dragonloot.network.SyncPacket; +import net.dragonloot.network.DragonLootClientPacket; +import net.dragonloot.network.DragonLootServerPacket; public class NetworkInit { - public static void init() { - SyncPacket.init(); + public static void serverInit() { + DragonLootServerPacket.init(); + } + + public static void clientInit() { + DragonLootClientPacket.init(); } } diff --git a/src/main/java/net/dragonloot/init/RenderInit.java b/src/main/java/net/dragonloot/init/RenderInit.java index 1430bce..389f49d 100644 --- a/src/main/java/net/dragonloot/init/RenderInit.java +++ b/src/main/java/net/dragonloot/init/RenderInit.java @@ -1,17 +1,21 @@ package net.dragonloot.init; +import net.dragonloot.DragonLootMain; import net.dragonloot.entity.model.DragonElytraEntityModel; import net.dragonloot.entity.render.DragonTridentEntityRenderer; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry; import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; import net.minecraft.client.render.entity.model.EntityModelLayer; -import net.minecraft.util.Identifier; +@Environment(EnvType.CLIENT) public class RenderInit { - public static final EntityModelLayer DRAGON_ELYTRA_LAYER = new EntityModelLayer(new Identifier("dragonloot:dragon_elytra_render_layer"), "dragon_elytra_render_layer"); + + public static final EntityModelLayer DRAGON_ELYTRA_LAYER = new EntityModelLayer(DragonLootMain.ID("dragon_elytra_render_layer"), "dragon_elytra_render_layer"); public static void init() { - EntityRendererRegistry.register(EntityInit.DRAGONTRIDENT_ENTITY, DragonTridentEntityRenderer::new); + EntityRendererRegistry.register(EntityInit.DRAGON_TRIDENT_ENTITY, DragonTridentEntityRenderer::new); EntityModelLayerRegistry.registerModelLayer(DRAGON_ELYTRA_LAYER, DragonElytraEntityModel::getTexturedModelData); } } \ No newline at end of file diff --git a/src/main/java/net/dragonloot/init/TagInit.java b/src/main/java/net/dragonloot/init/TagInit.java index b961be3..72225cc 100644 --- a/src/main/java/net/dragonloot/init/TagInit.java +++ b/src/main/java/net/dragonloot/init/TagInit.java @@ -6,10 +6,10 @@ import net.minecraft.util.Identifier; public class TagInit { - public static final TagKey NOT_DESTROYED_BY_EXPLOSION = TagKey.of(RegistryKeys.ITEM, new Identifier("dragonloot", "explosion_resistant")); - public static void init() { + public static final TagKey NOT_DESTROYED_BY_EXPLOSION = TagKey.of(RegistryKeys.ITEM, Identifier.of("dragonloot", "explosion_resistant")); + public static void init() { } } diff --git a/src/main/java/net/dragonloot/item/DragonArmor.java b/src/main/java/net/dragonloot/item/DragonArmor.java deleted file mode 100644 index 47f2fbf..0000000 --- a/src/main/java/net/dragonloot/item/DragonArmor.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.dragonloot.item; - -import java.util.UUID; - -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.ImmutableMultimap.Builder; - -import net.minecraft.block.DispenserBlock; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.item.ArmorItem; -import net.minecraft.item.ArmorMaterial; - -public class DragonArmor extends ArmorItem { - private static final UUID[] MODIFIERS = new UUID[] { UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150") }; - private final Multimap attributeModifiers; - private final int protection; - private final float toughness; - protected final float knockbackResistance; - protected final EquipmentSlot slot; - protected final ArmorMaterial material; - - public DragonArmor(ArmorMaterial material, ArmorItem.Type type, Settings settings) { - super(material, type, settings); - this.material = material; - this.slot = type.getEquipmentSlot(); - this.protection = material.getProtection(type); - this.toughness = material.getToughness(); - this.knockbackResistance = material.getKnockbackResistance(); - DispenserBlock.registerBehavior(this, DISPENSER_BEHAVIOR); - Builder builder = ImmutableMultimap.builder(); - UUID uUID = MODIFIERS[slot.getEntitySlotId()]; - builder.put(EntityAttributes.GENERIC_ARMOR, new EntityAttributeModifier(uUID, "Armor modifier", (double) this.protection, EntityAttributeModifier.Operation.ADDITION)); - builder.put(EntityAttributes.GENERIC_ARMOR_TOUGHNESS, new EntityAttributeModifier(uUID, "Armor toughness", (double) this.toughness, EntityAttributeModifier.Operation.ADDITION)); - builder.put(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(uUID, "Armor knockback resistance", (double) this.knockbackResistance / 10D, EntityAttributeModifier.Operation.ADDITION)); - this.attributeModifiers = builder.build(); - } - - @Override - public Multimap getAttributeModifiers(EquipmentSlot slot) { - return slot == this.slot ? this.attributeModifiers : super.getAttributeModifiers(slot); - } - -} diff --git a/src/main/java/net/dragonloot/item/DragonArmorMaterial.java b/src/main/java/net/dragonloot/item/DragonArmorMaterial.java deleted file mode 100644 index d0e1ddb..0000000 --- a/src/main/java/net/dragonloot/item/DragonArmorMaterial.java +++ /dev/null @@ -1,68 +0,0 @@ -package net.dragonloot.item; - -import net.dragonloot.init.ConfigInit; -import net.dragonloot.init.ItemInit; -import net.minecraft.item.ArmorItem; -import net.minecraft.item.ArmorMaterial; -import net.minecraft.recipe.Ingredient; -import net.minecraft.sound.SoundEvent; -import net.minecraft.sound.SoundEvents; - -public class DragonArmorMaterial implements ArmorMaterial { - - private DragonArmorMaterial() { - } - - private static DragonArmorMaterial INSTANCE = null; - - public static DragonArmorMaterial getInstance() { - if (INSTANCE == null) { - INSTANCE = new DragonArmorMaterial(); - } - return INSTANCE; - } - - private static final int[] BASE_DURABILITY = new int[] { 28, 32, 35, 26 }; - private static final int[] PROTECTION_AMOUNTS = new int[] { ConfigInit.CONFIG.dragon_armor_protection_boots, ConfigInit.CONFIG.dragon_armor_protection_leggings, ConfigInit.CONFIG.dragon_armor_protection_chest, ConfigInit.CONFIG.dragon_armor_protection_helmet }; - - @Override - public int getDurability(ArmorItem.Type type) { - return BASE_DURABILITY[type.getEquipmentSlot().getEntitySlotId()] * ConfigInit.CONFIG.dragon_armor_durability_multiplier; - } - - @Override - public int getProtection(ArmorItem.Type type) { - return PROTECTION_AMOUNTS[type.getEquipmentSlot().getEntitySlotId()]; - } - - @Override - public int getEnchantability() { - return ConfigInit.CONFIG.dragon_armor_enchantability; - } - - @Override - public SoundEvent getEquipSound() { - return SoundEvents.ITEM_ARMOR_EQUIP_CHAIN; - } - - @Override - public Ingredient getRepairIngredient() { - return Ingredient.ofItems(ItemInit.DRAGON_SCALE_ITEM); - } - - @Override - public String getName() { - return "dragon"; - } - - @Override - public float getToughness() { - return ConfigInit.CONFIG.dragon_armor_toughness; - } - - @Override - public float getKnockbackResistance() { - return ConfigInit.CONFIG.dragon_armor_knockback_resistance; - } - -} \ No newline at end of file diff --git a/src/main/java/net/dragonloot/item/DragonArmorMaterials.java b/src/main/java/net/dragonloot/item/DragonArmorMaterials.java new file mode 100644 index 0000000..539c404 --- /dev/null +++ b/src/main/java/net/dragonloot/item/DragonArmorMaterials.java @@ -0,0 +1,40 @@ +package net.dragonloot.item; + +import java.util.EnumMap; +import java.util.List; +import java.util.function.Supplier; + +import net.dragonloot.init.ConfigInit; +import net.dragonloot.init.ItemInit; +import net.minecraft.item.ArmorItem; +import net.minecraft.item.ArmorMaterial; +import net.minecraft.recipe.Ingredient; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.sound.SoundEvent; +import net.minecraft.sound.SoundEvents; +import net.minecraft.util.Identifier; +import net.minecraft.util.Util; + +public class DragonArmorMaterials { + + public static final RegistryEntry DRAGON = register("dragonloot:dragon", Util.make(new EnumMap<>(ArmorItem.Type.class), map -> { + map.put(ArmorItem.Type.BOOTS, ConfigInit.CONFIG.dragon_armor_protection_boots); + map.put(ArmorItem.Type.LEGGINGS, ConfigInit.CONFIG.dragon_armor_protection_leggings); + map.put(ArmorItem.Type.CHESTPLATE, ConfigInit.CONFIG.dragon_armor_protection_chest); + map.put(ArmorItem.Type.HELMET, ConfigInit.CONFIG.dragon_armor_protection_helmet); + map.put(ArmorItem.Type.BODY, ConfigInit.CONFIG.dragon_armor_protection_chest); + }), ConfigInit.CONFIG.dragon_armor_enchantability, SoundEvents.ITEM_ARMOR_EQUIP_NETHERITE, ConfigInit.CONFIG.dragon_armor_toughness, ConfigInit.CONFIG.dragon_armor_knockback_resistance, () -> Ingredient.ofItems(ItemInit.DRAGON_SCALE)); + + private static RegistryEntry register(String id, EnumMap defense, int enchantability, RegistryEntry equipSound, float toughness, float knockbackResistance, Supplier repairIngredient) { + List list = List.of(new ArmorMaterial.Layer(Identifier.of(id))); + + EnumMap enumMap = new EnumMap(ArmorItem.Type.class); + for (ArmorItem.Type type : ArmorItem.Type.values()) { + enumMap.put(type, defense.get(type)); + } + return Registry.registerReference(Registries.ARMOR_MATERIAL, Identifier.of(id), new ArmorMaterial(enumMap, enchantability, equipSound, repairIngredient, list, toughness, knockbackResistance)); + } + +} diff --git a/src/main/java/net/dragonloot/item/DragonAxeItem.java b/src/main/java/net/dragonloot/item/DragonAxeItem.java deleted file mode 100644 index 6859f1a..0000000 --- a/src/main/java/net/dragonloot/item/DragonAxeItem.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.dragonloot.item; - -import net.minecraft.item.AxeItem; -import net.minecraft.item.ToolMaterial; - -public class DragonAxeItem extends AxeItem { - - public DragonAxeItem(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) { - super(material, attackDamage, attackSpeed, settings); - } - -} diff --git a/src/main/java/net/dragonloot/item/DragonBowItem.java b/src/main/java/net/dragonloot/item/DragonBowItem.java deleted file mode 100644 index 46432dd..0000000 --- a/src/main/java/net/dragonloot/item/DragonBowItem.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.dragonloot.item; - -import net.minecraft.item.BowItem; - -public class DragonBowItem extends BowItem { - - public DragonBowItem(Settings settings) { - super(settings); - } - -} diff --git a/src/main/java/net/dragonloot/item/DragonCrossbowItem.java b/src/main/java/net/dragonloot/item/DragonCrossbowItem.java deleted file mode 100644 index dccf7bd..0000000 --- a/src/main/java/net/dragonloot/item/DragonCrossbowItem.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.dragonloot.item; - -import net.dragonloot.init.ItemInit; -import net.minecraft.item.CrossbowItem; -import net.minecraft.item.ItemStack; - -public class DragonCrossbowItem extends CrossbowItem { - - public DragonCrossbowItem(Settings settings) { - super(settings); - } - - @Override - public boolean isUsedOnRelease(ItemStack stack) { - return stack.getItem() == ItemInit.DRAGON_CROSSBOW_ITEM; - } -} diff --git a/src/main/java/net/dragonloot/item/DragonHoeItem.java b/src/main/java/net/dragonloot/item/DragonHoeItem.java deleted file mode 100644 index 1835ef6..0000000 --- a/src/main/java/net/dragonloot/item/DragonHoeItem.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.dragonloot.item; - -import net.minecraft.item.HoeItem; -import net.minecraft.item.ToolMaterial; - -public class DragonHoeItem extends HoeItem { - - public DragonHoeItem(ToolMaterial material, int attackDamage, float attackSpeed, Settings settings) { - super(material, attackDamage, attackSpeed, settings); - } - -} diff --git a/src/main/java/net/dragonloot/item/DragonPickaxeItem.java b/src/main/java/net/dragonloot/item/DragonPickaxeItem.java deleted file mode 100644 index 5f53539..0000000 --- a/src/main/java/net/dragonloot/item/DragonPickaxeItem.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.dragonloot.item; - -import net.minecraft.item.PickaxeItem; -import net.minecraft.item.ToolMaterial; - -public class DragonPickaxeItem extends PickaxeItem { - - public DragonPickaxeItem(ToolMaterial material, int attackDamage, float attackSpeed, Settings settings) { - super(material, attackDamage, attackSpeed, settings); - } - -} diff --git a/src/main/java/net/dragonloot/item/DragonScaleItem.java b/src/main/java/net/dragonloot/item/DragonScaleItem.java deleted file mode 100644 index 823284b..0000000 --- a/src/main/java/net/dragonloot/item/DragonScaleItem.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.dragonloot.item; - -import net.minecraft.item.Item; - -public class DragonScaleItem extends Item { - - public DragonScaleItem(Settings settings) { - super(settings); - } - -} diff --git a/src/main/java/net/dragonloot/item/DragonShovelItem.java b/src/main/java/net/dragonloot/item/DragonShovelItem.java deleted file mode 100644 index edeac35..0000000 --- a/src/main/java/net/dragonloot/item/DragonShovelItem.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.dragonloot.item; - -import net.minecraft.item.ShovelItem; -import net.minecraft.item.ToolMaterial; - -public class DragonShovelItem extends ShovelItem { - - public DragonShovelItem(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) { - super(material, attackDamage, attackSpeed, settings); - } - -} diff --git a/src/main/java/net/dragonloot/item/DragonSwordItem.java b/src/main/java/net/dragonloot/item/DragonSwordItem.java deleted file mode 100644 index 9fb4c44..0000000 --- a/src/main/java/net/dragonloot/item/DragonSwordItem.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.dragonloot.item; - -import net.minecraft.item.SwordItem; -import net.minecraft.item.ToolMaterial; - -public class DragonSwordItem extends SwordItem { - - public DragonSwordItem(ToolMaterial toolMaterial, int attackDamage, float attackSpeed, Settings settings) { - super(toolMaterial, attackDamage, attackSpeed, settings); - } - -} diff --git a/src/main/java/net/dragonloot/item/DragonToolMaterial.java b/src/main/java/net/dragonloot/item/DragonToolMaterial.java deleted file mode 100644 index 7a953f0..0000000 --- a/src/main/java/net/dragonloot/item/DragonToolMaterial.java +++ /dev/null @@ -1,58 +0,0 @@ -package net.dragonloot.item; - -import net.dragonloot.init.ConfigInit; -import net.dragonloot.init.ItemInit; -import net.minecraft.item.ToolMaterial; -import net.minecraft.recipe.Ingredient; - -public class DragonToolMaterial implements ToolMaterial { - - private DragonToolMaterial() { - } - - private static DragonToolMaterial INSTANCE = null; - - public static DragonToolMaterial getInstance() { - if (INSTANCE == null) { - INSTANCE = new DragonToolMaterial(); - } - return INSTANCE; - } - - @Override - public int getDurability() { - return 67 * ConfigInit.CONFIG.dragon_item_durability_multiplier; - } - - @Override - public float getMiningSpeedMultiplier() { - return 12; - } - - @Override - public float getAttackDamage() { - return ConfigInit.CONFIG.dragon_item_base_damage; - } - - @Override - public int getMiningLevel() { - return 5; - } - - @Override - public int getEnchantability() { - return ConfigInit.CONFIG.dragon_tool_enchantability; - } - - @Override - public Ingredient getRepairIngredient() { - return Ingredient.ofItems(ItemInit.DRAGON_SCALE_ITEM); - } - - // For LevelZ compat - @Override - public String toString() { - return "DRAGON"; - } - -} diff --git a/src/main/java/net/dragonloot/item/DragonToolMaterials.java b/src/main/java/net/dragonloot/item/DragonToolMaterials.java new file mode 100644 index 0000000..ebd86fc --- /dev/null +++ b/src/main/java/net/dragonloot/item/DragonToolMaterials.java @@ -0,0 +1,67 @@ +package net.dragonloot.item; + +import net.dragonloot.init.ConfigInit; +import net.dragonloot.init.ItemInit; +import net.minecraft.block.Block; +import net.minecraft.item.ToolMaterial; +import net.minecraft.recipe.Ingredient; +import net.minecraft.registry.tag.BlockTags; +import net.minecraft.registry.tag.TagKey; + +public class DragonToolMaterials implements ToolMaterial { + + public static final ToolMaterial DRAGON = new DragonToolMaterials(BlockTags.INCORRECT_FOR_WOODEN_TOOL, ConfigInit.CONFIG.dragon_item_durability_multiplier, ConfigInit.CONFIG.dragon_item_mining_speed_multiplier, ConfigInit.CONFIG.dragon_item_base_damage, ConfigInit.CONFIG.dragon_tool_enchantability, Ingredient.ofItems(ItemInit.DRAGON_SCALE), "dragon"); + + private final TagKey inverseTag; + private final int itemDurability; + private final float miningSpeed; + private final float attackDamage; + private final int enchantability; + private final Ingredient repairIngredient; + private final String name; + + private DragonToolMaterials(TagKey inverseTag, int itemDurability, float miningSpeed, float attackDamage, int enchantability, Ingredient repairIngredient, String name) { + this.inverseTag = inverseTag; + this.itemDurability = itemDurability; + this.miningSpeed = miningSpeed; + this.attackDamage = attackDamage; + this.enchantability = enchantability; + this.repairIngredient = repairIngredient; + this.name = name; + } + + @Override + public int getDurability() { + return this.itemDurability; + } + + @Override + public float getMiningSpeedMultiplier() { + return this.miningSpeed; + } + + @Override + public float getAttackDamage() { + return this.attackDamage; + } + + @Override + public TagKey getInverseTag() { + return this.inverseTag; + } + + @Override + public int getEnchantability() { + return this.enchantability; + } + + @Override + public Ingredient getRepairIngredient() { + return this.repairIngredient; + } + + @Override + public String toString() { + return this.name; + } +} diff --git a/src/main/java/net/dragonloot/item/DragonTridentItem.java b/src/main/java/net/dragonloot/item/DragonTridentItem.java index 2bf3f21..66f4c5d 100644 --- a/src/main/java/net/dragonloot/item/DragonTridentItem.java +++ b/src/main/java/net/dragonloot/item/DragonTridentItem.java @@ -1,108 +1,80 @@ package net.dragonloot.item; import net.dragonloot.entity.DragonTridentEntity; -import net.dragonloot.init.ConfigInit; +import net.minecraft.component.EnchantmentEffectComponentTypes; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.MovementType; -import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.PersistentProjectileEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.TridentItem; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; import net.minecraft.stat.Stats; -import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; public class DragonTridentItem extends TridentItem { - public DragonTridentItem(Settings settings) { + public DragonTridentItem(Item.Settings settings) { super(settings); - attributeModifiers.get(EntityAttributes.GENERIC_ATTACK_DAMAGE).forEach(modifier -> { - modifier.value = modifier.getValue() + ConfigInit.CONFIG.dragon_item_base_damage / 5F; - }); } @Override public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) { - if (user instanceof PlayerEntity) { - PlayerEntity playerEntity = (PlayerEntity) user; - int i = getMaxUseTime(stack) - remainingUseTicks; - if (i >= 10) { - int riptideLevel = EnchantmentHelper.getRiptide(stack); - if (riptideLevel <= 0 || playerEntity.isTouchingWaterOrRain() || playerEntity.isInLava()) { - if (!world.isClient) { - stack.damage(1, playerEntity, (p) -> { - p.sendToolBreakStatus(user.getActiveHand()); - }); - if (riptideLevel == 0) { - DragonTridentEntity tridentEntity = new DragonTridentEntity(world, playerEntity, stack); - tridentEntity.setVelocity(playerEntity, playerEntity.getPitch(), playerEntity.getYaw(), 0.0F, 2.5F + riptideLevel * 0.5F, 1.0F); - if (playerEntity.isCreative()) { - tridentEntity.pickupType = PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY; - } - - world.spawnEntity(tridentEntity); - world.playSoundFromEntity(null, tridentEntity, SoundEvents.ITEM_TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F); - if (!playerEntity.isCreative()) { - playerEntity.getInventory().removeOne(stack); - } - } - } - - playerEntity.incrementStat(Stats.USED.getOrCreateStat(this)); - if (riptideLevel > 0) { - float f = playerEntity.getYaw(); - float g = playerEntity.getPitch(); - float h = -MathHelper.sin(f * 0.017453292F) * MathHelper.cos(g * 0.017453292F); - float k = -MathHelper.sin(g * 0.017453292F); - float l = MathHelper.cos(f * 0.017453292F) * MathHelper.cos(g * 0.017453292F); - float m = MathHelper.sqrt(h * h + k * k + l * l); - float n = 3.0F * ((1.0F + riptideLevel) / 4.0F); - h *= n / m; - k *= n / m; - l *= n / m; - playerEntity.addVelocity(h, k, l); - playerEntity.useRiptide(20); - if (playerEntity.isOnGround()) { - float o = 1.1999999F; - playerEntity.move(MovementType.SELF, new Vec3d(0.0D, o, 0.0D)); - } - - SoundEvent soundEvent3; - if (riptideLevel >= 3) { - soundEvent3 = SoundEvents.ITEM_TRIDENT_RIPTIDE_3; - } else if (riptideLevel == 2) { - soundEvent3 = SoundEvents.ITEM_TRIDENT_RIPTIDE_2; - } else { - soundEvent3 = SoundEvents.ITEM_TRIDENT_RIPTIDE_1; - } - - world.playSoundFromEntity(null, playerEntity, soundEvent3, SoundCategory.PLAYERS, 1.0F, 1.0F); - - } - + if (!(user instanceof PlayerEntity playerEntity)) { + return; + } + int i = this.getMaxUseTime(stack, user) - remainingUseTicks; + if (i < 10) { + return; + } + float f = EnchantmentHelper.getTridentSpinAttackStrength(stack, playerEntity); + if (f > 0.0f && !playerEntity.isTouchingWaterOrRain()) { + return; + } + if (isAboutToBreak(stack)) { + return; + } + RegistryEntry registryEntry = EnchantmentHelper.getEffect(stack, EnchantmentEffectComponentTypes.TRIDENT_SOUND).orElse(SoundEvents.ITEM_TRIDENT_THROW); + if (!world.isClient()) { + stack.damage(1, playerEntity, LivingEntity.getSlotForHand(user.getActiveHand())); + if (f == 0.0f) { + DragonTridentEntity tridentEntity = new DragonTridentEntity(world, playerEntity, stack); + tridentEntity.setVelocity(playerEntity, playerEntity.getPitch(), playerEntity.getYaw(), 0.0f, 2.5f, 1.0f); + if (playerEntity.isInCreativeMode()) { + tridentEntity.pickupType = PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY; + } + world.spawnEntity(tridentEntity); + world.playSoundFromEntity(null, tridentEntity, registryEntry.value(), SoundCategory.PLAYERS, 1.0f, 1.0f); + if (!playerEntity.isInCreativeMode()) { + playerEntity.getInventory().removeOne(stack); } } } + playerEntity.incrementStat(Stats.USED.getOrCreateStat(this)); + if (f > 0.0f) { + float g = playerEntity.getYaw(); + float h = playerEntity.getPitch(); + float j = -MathHelper.sin(g * ((float) Math.PI / 180)) * MathHelper.cos(h * ((float) Math.PI / 180)); + float k = -MathHelper.sin(h * ((float) Math.PI / 180)); + float l = MathHelper.cos(g * ((float) Math.PI / 180)) * MathHelper.cos(h * ((float) Math.PI / 180)); + float m = MathHelper.sqrt(j * j + k * k + l * l); + playerEntity.addVelocity(j *= f / m, k *= f / m, l *= f / m); + playerEntity.useRiptide(20, 8.0f, stack); + if (playerEntity.isOnGround()) { + playerEntity.move(MovementType.SELF, new Vec3d(0.0, 1.1999999284744263, 0.0)); + } + world.playSoundFromEntity(null, playerEntity, registryEntry.value(), SoundCategory.PLAYERS, 1.0f, 1.0f); + } } - @Override - public TypedActionResult use(World world, PlayerEntity user, Hand hand) { - ItemStack itemStack = user.getStackInHand(hand); - if (itemStack.getDamage() >= itemStack.getMaxDamage() - 1) { - return TypedActionResult.fail(itemStack); - } else if (EnchantmentHelper.getRiptide(itemStack) > 0 && !(user.isTouchingWaterOrRain() || user.isInLava())) { - return TypedActionResult.fail(itemStack); - } else { - user.setCurrentHand(hand); - return TypedActionResult.consume(itemStack); - } + private static boolean isAboutToBreak(ItemStack stack) { + return stack.getDamage() >= stack.getMaxDamage() - 1; } } diff --git a/src/main/java/net/dragonloot/item/render/DragonTridentItemRenderer.java b/src/main/java/net/dragonloot/item/render/DragonTridentItemRenderer.java index d00c80c..06c5288 100644 --- a/src/main/java/net/dragonloot/item/render/DragonTridentItemRenderer.java +++ b/src/main/java/net/dragonloot/item/render/DragonTridentItemRenderer.java @@ -16,7 +16,7 @@ public static void render(ItemStack stack, ModelTransformationMode mode, MatrixS matrices.push(); matrices.scale(1.0F, -1.0F, -1.0F); VertexConsumer vertexConsumer2 = ItemRenderer.getDirectItemGlintConsumer(vertexConsumers, modelTrident.getLayer(DragonLootMain.ID("textures/entity/dragon_trident.png")), false, stack.hasGlint()); - modelTrident.render(matrices, vertexConsumer2, light, overlay, 1.0F, 1.0F, 1.0F, 1.0F); + modelTrident.render(matrices, vertexConsumer2, light, overlay); matrices.pop(); } diff --git a/src/main/java/net/dragonloot/mixin/AnvilScreenHandlerMixin.java b/src/main/java/net/dragonloot/mixin/AnvilScreenHandlerMixin.java index 8e823a3..cc31765 100644 --- a/src/main/java/net/dragonloot/mixin/AnvilScreenHandlerMixin.java +++ b/src/main/java/net/dragonloot/mixin/AnvilScreenHandlerMixin.java @@ -6,20 +6,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import io.netty.buffer.Unpooled; - import org.spongepowered.asm.mixin.injection.At; import net.dragonloot.access.DragonAnvilInterface; import net.dragonloot.init.BlockInit; import net.dragonloot.init.ConfigInit; -import net.dragonloot.network.SyncPacket; +import net.dragonloot.network.packet.AnvilPacket; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketByteBuf; import net.minecraft.screen.AnvilScreenHandler; import net.minecraft.screen.ForgingScreenHandler; import net.minecraft.screen.Property; @@ -42,10 +39,7 @@ public AnvilScreenHandlerMixin(ScreenHandlerType type, int syncId, PlayerInve private void canUseMixin(BlockState state, CallbackInfoReturnable info) { if (state.isOf(BlockInit.DRAGON_ANVIL_BLOCK)) { isDragonAnvil = true; - PacketByteBuf data = new PacketByteBuf(Unpooled.buffer()); - data.writeInt(player.getId()); - data.writeString(state.getBlock().toString()); - ServerPlayNetworking.send((ServerPlayerEntity) player, SyncPacket.ANVIL_SYNC_PACKET, data); + ServerPlayNetworking.send((ServerPlayerEntity) player, new AnvilPacket(player.getId(), state.getBlock().toString())); } } diff --git a/src/main/java/net/dragonloot/mixin/BowItemMixin.java b/src/main/java/net/dragonloot/mixin/BowItemMixin.java deleted file mode 100644 index 1e4f71d..0000000 --- a/src/main/java/net/dragonloot/mixin/BowItemMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.dragonloot.mixin; - -import net.dragonloot.item.DragonBowItem; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.projectile.PersistentProjectileEntity; -import net.minecraft.item.ArrowItem; -import net.minecraft.item.BowItem; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -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.spongepowered.asm.mixin.injection.callback.LocalCapture; - -@Mixin(BowItem.class) -public class BowItemMixin { - - @Inject(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/enchantment/EnchantmentHelper;getLevel(Lnet/minecraft/enchantment/Enchantment;Lnet/minecraft/item/ItemStack;)I", ordinal = 3), locals = LocalCapture.CAPTURE_FAILSOFT) - private void onStoppedUsingMixin(ItemStack stack, World world, LivingEntity user, int remainingUseTicks, CallbackInfo info, PlayerEntity playerEntity, boolean bl, ItemStack itemStack, int i, float f, boolean bl2, ArrowItem arrowItem, PersistentProjectileEntity persistentProjectileEntity) { - if (stack.getItem() instanceof DragonBowItem) { - persistentProjectileEntity.setDamage(persistentProjectileEntity.getDamage() * 1.25f + 1f); - } - } - -} diff --git a/src/main/java/net/dragonloot/mixin/CrossbowItemMixin.java b/src/main/java/net/dragonloot/mixin/CrossbowItemMixin.java deleted file mode 100644 index 07bce1c..0000000 --- a/src/main/java/net/dragonloot/mixin/CrossbowItemMixin.java +++ /dev/null @@ -1,45 +0,0 @@ -package net.dragonloot.mixin; - -import net.dragonloot.init.ItemInit; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.projectile.PersistentProjectileEntity; -import net.minecraft.item.ArrowItem; -import net.minecraft.item.CrossbowItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -@Mixin(CrossbowItem.class) -public class CrossbowItemMixin { - - @Inject(method = "createArrow", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILSOFT, cancellable = true) - private static void createArrowMixin(World world, LivingEntity entity, ItemStack crossbow, ItemStack arrow, CallbackInfoReturnable info, ArrowItem arrowItem, PersistentProjectileEntity persistentProjectileEntity) { - if (crossbow.getItem() == ItemInit.DRAGON_CROSSBOW_ITEM) { - persistentProjectileEntity.setDamage(persistentProjectileEntity.getDamage() * 1.25f + 1f); - info.setReturnValue(persistentProjectileEntity); - } - } - - @Inject(method = "getSpeed", at = @At("HEAD"), cancellable = true) - private static void getSpeedMixin(ItemStack stack, CallbackInfoReturnable info) { - if (stack.getItem() == ItemInit.DRAGON_CROSSBOW_ITEM) { - if (hasProjectile(stack, Items.FIREWORK_ROCKET)) { - info.setReturnValue(1.6F); - } else { - info.setReturnValue(3.15F); - } - } - } - - @Shadow - public static boolean hasProjectile(ItemStack crossbow, Item projectile) { - return false; - } -} \ No newline at end of file diff --git a/src/main/java/net/dragonloot/mixin/EnderDragonEntityMixin.java b/src/main/java/net/dragonloot/mixin/EnderDragonEntityMixin.java index 805aa54..55a08de 100644 --- a/src/main/java/net/dragonloot/mixin/EnderDragonEntityMixin.java +++ b/src/main/java/net/dragonloot/mixin/EnderDragonEntityMixin.java @@ -43,11 +43,11 @@ protected void updatePostDeathMixin(CallbackInfo info) { } for (int i = 0; i < (ConfigInit.CONFIG.scale_minimum_drop_amount); i++) { - this.dropStack(new ItemStack(ItemInit.DRAGON_SCALE_ITEM)); + this.dropStack(new ItemStack(ItemInit.DRAGON_SCALE)); } for (int u = 0; u < dragonscalebonus; u++) { if (this.getWorld().getRandom().nextFloat() <= ConfigInit.CONFIG.additional_scale_drop_chance) { - this.dropStack(new ItemStack(ItemInit.DRAGON_SCALE_ITEM)); + this.dropStack(new ItemStack(ItemInit.DRAGON_SCALE)); } } diff --git a/src/main/java/net/dragonloot/mixin/LivingEntityMixin.java b/src/main/java/net/dragonloot/mixin/LivingEntityMixin.java index 3a9de2f..e2b2577 100644 --- a/src/main/java/net/dragonloot/mixin/LivingEntityMixin.java +++ b/src/main/java/net/dragonloot/mixin/LivingEntityMixin.java @@ -11,12 +11,17 @@ import net.minecraft.entity.EntityType; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.LivingEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.sound.SoundEvents; import net.minecraft.world.World; +import net.minecraft.world.event.GameEvent; @Mixin(LivingEntity.class) public abstract class LivingEntityMixin extends Entity { + @Shadow - protected int roll; + protected int fallFlyingTicks; public LivingEntityMixin(EntityType type, World world) { super(type, world); @@ -29,7 +34,35 @@ private void tickFallFlyingMixin(CallbackInfo info) { this.setFlag(7, true); info.cancel(); } + } + + @Inject(method = "tickFallFlying", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/entity/LivingEntity;getEquippedStack(Lnet/minecraft/entity/EquipmentSlot;)Lnet/minecraft/item/ItemStack;")) + private void tickFallFlyingSecondMixin(CallbackInfo info) { + ItemStack itemStack = this.getEquippedStack(EquipmentSlot.CHEST); + if (itemStack.isOf(ItemInit.UPGRADED_DRAGON_CHESTPLATE)) { + if (itemStack.getDamage() < itemStack.getMaxDamage() - 1) { + int i = this.fallFlyingTicks + 1; + if (!this.getWorld().isClient() && i % 10 == 0) { + int j = i / 10; + if (j % 2 == 0) { + itemStack.damage(1, (LivingEntity) (Object) this, EquipmentSlot.CHEST); + } + this.emitGameEvent(GameEvent.ELYTRA_GLIDE); + } + } else if ((Object) this instanceof LivingEntity livingEntity) { + if (!this.getWorld().isClient()) { + itemStack = new ItemStack(Items.ELYTRA); + itemStack.setDamage(Items.ELYTRA.getDefaultStack().getMaxDamage()); + } + if (!livingEntity.isSilent()) { + livingEntity.getWorld().playSound(livingEntity.getX(), livingEntity.getY(), livingEntity.getZ(), SoundEvents.ENTITY_ITEM_BREAK, livingEntity.getSoundCategory(), 0.8F, 0.8F + livingEntity.getWorld().getRandom().nextFloat() * 0.4F, false); + } + } + } } + @Shadow + public abstract ItemStack getEquippedStack(EquipmentSlot equipmentSlot); + } \ No newline at end of file diff --git a/src/main/java/net/dragonloot/mixin/PlayerInventoryMixin.java b/src/main/java/net/dragonloot/mixin/PlayerInventoryMixin.java deleted file mode 100644 index 5f28db0..0000000 --- a/src/main/java/net/dragonloot/mixin/PlayerInventoryMixin.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.dragonloot.mixin; - -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.At; - -import net.dragonloot.init.ItemInit; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.sound.SoundEvents; -import net.minecraft.util.collection.DefaultedList; - -@Mixin(PlayerInventory.class) -public class PlayerInventoryMixin { - @Shadow - public final PlayerEntity player; - @Shadow - @Final - @Mutable - public final DefaultedList armor; - - public PlayerInventoryMixin(PlayerEntity player) { - this.armor = DefaultedList.ofSize(4, ItemStack.EMPTY); - this.player = player; - } - - @Inject(method = "damageArmor", at = @At("HEAD"), cancellable = true) - private void damageArmorMixin(DamageSource damageSource, float amount, int[] slots, CallbackInfo info) { - ItemStack item = this.armor.get(2); - if (amount > 0.0F && item.getItem().equals(ItemInit.UPGRADED_DRAGON_CHESTPLATE) && item.getDamage() == (item.getMaxDamage() - 1)) { - this.armor.get(2).decrement(1); - this.armor.set(2, new ItemStack(Items.ELYTRA)); - this.armor.get(2).setDamage(Items.ELYTRA.getMaxDamage()); - if (!this.player.isSilent()) { - this.player.getWorld().playSound(this.player.getX(), this.player.getY(), this.player.getZ(), SoundEvents.ENTITY_ITEM_BREAK, this.player.getSoundCategory(), 0.8F, 0.8F + this.player.getWorld().getRandom().nextFloat() * 0.4F, false); - } - } - } - -} diff --git a/src/main/java/net/dragonloot/mixin/RangedWeaponItemMixin.java b/src/main/java/net/dragonloot/mixin/RangedWeaponItemMixin.java new file mode 100644 index 0000000..999d4fb --- /dev/null +++ b/src/main/java/net/dragonloot/mixin/RangedWeaponItemMixin.java @@ -0,0 +1,36 @@ +package net.dragonloot.mixin; + +import java.util.List; + +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import net.dragonloot.init.ItemInit; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.projectile.PersistentProjectileEntity; +import net.minecraft.entity.projectile.ProjectileEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.RangedWeaponItem; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.Hand; + +@Mixin(RangedWeaponItem.class) +public class RangedWeaponItemMixin { + + @Inject(method = "shootAll", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/RangedWeaponItem;shoot(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/entity/projectile/ProjectileEntity;IFFFLnet/minecraft/entity/LivingEntity;)V"), locals = LocalCapture.CAPTURE_FAILSOFT) + protected void shootAllMixin(ServerWorld world, LivingEntity shooter, Hand hand, ItemStack stack, List projectiles, float speed, float divergence, boolean critical, @Nullable LivingEntity target, CallbackInfo info, float f, float g, float h, float i, int j, ItemStack itemStack, float k, ProjectileEntity projectileEntity) { + if (projectileEntity instanceof PersistentProjectileEntity persistentProjectileEntity) { + Item item = shooter.getStackInHand(hand).getItem(); + if (item == ItemInit.DRAGON_CROSSBOW) { + persistentProjectileEntity.setDamage(persistentProjectileEntity.getDamage() * 1.25f + 1f); + } else if (item == ItemInit.DRAGON_BOW) { + persistentProjectileEntity.setDamage(persistentProjectileEntity.getDamage() * 1.25f + 1f); + } + } + } +} diff --git a/src/main/java/net/dragonloot/mixin/client/AbstractClientPlayerEntityMixin.java b/src/main/java/net/dragonloot/mixin/client/AbstractClientPlayerEntityMixin.java index 71301fa..9776199 100644 --- a/src/main/java/net/dragonloot/mixin/client/AbstractClientPlayerEntityMixin.java +++ b/src/main/java/net/dragonloot/mixin/client/AbstractClientPlayerEntityMixin.java @@ -29,7 +29,7 @@ public AbstractClientPlayerEntityMixin(World world, BlockPos pos, float yaw, Gam @SuppressWarnings("resource") @Inject(method = "getFovMultiplier", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;getActiveItem()Lnet/minecraft/item/ItemStack;"), locals = LocalCapture.CAPTURE_FAILSOFT, cancellable = true) private void getFovMultiplierMixin(CallbackInfoReturnable info, float f) { - if (this.isUsingItem() && this.getActiveItem().getItem().equals(ItemInit.DRAGON_BOW_ITEM)) { + if (this.isUsingItem() && this.getActiveItem().getItem().equals(ItemInit.DRAGON_BOW)) { int i = this.getItemUseTime(); float g = (float) i / 20.0f; g = g > 1.0f ? 1.0f : (g *= g); diff --git a/src/main/java/net/dragonloot/mixin/client/ElytraFeatureRendererMixin.java b/src/main/java/net/dragonloot/mixin/client/ElytraFeatureRendererMixin.java index a2fcca1..24c2ed5 100644 --- a/src/main/java/net/dragonloot/mixin/client/ElytraFeatureRendererMixin.java +++ b/src/main/java/net/dragonloot/mixin/client/ElytraFeatureRendererMixin.java @@ -27,7 +27,7 @@ @Environment(EnvType.CLIENT) @Mixin(ElytraFeatureRenderer.class) public abstract class ElytraFeatureRendererMixin> extends FeatureRenderer { - private static final Identifier DRAGON_ELYTRA_TEXTURE = new Identifier("dragonloot:textures/entity/dragon_elytra.png"); + private static final Identifier DRAGON_ELYTRA_TEXTURE = Identifier.of("dragonloot:textures/entity/dragon_elytra.png"); private final DragonElytraEntityModel dragonElytraModel = new DragonElytraEntityModel<>(DragonElytraEntityModel.getTexturedModelData().createModel()); public ElytraFeatureRendererMixin(FeatureRendererContext context) { @@ -42,8 +42,8 @@ private void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsum matrixStack.translate(0.0D, 0.0D, 0.02D); this.getContextModel().copyStateTo(this.dragonElytraModel); this.dragonElytraModel.setAngles(livingEntity, f, g, j, k, l); - VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumerProvider, RenderLayer.getArmorCutoutNoCull(DRAGON_ELYTRA_TEXTURE), false, itemStack.hasGlint()); - this.dragonElytraModel.render(matrixStack, vertexConsumer, i, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F); + VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumerProvider, RenderLayer.getArmorCutoutNoCull(DRAGON_ELYTRA_TEXTURE), false); + this.dragonElytraModel.render(matrixStack, vertexConsumer, i, OverlayTexture.DEFAULT_UV); matrixStack.pop(); info.cancel(); } diff --git a/src/main/java/net/dragonloot/mixin/client/HeadFeatureRendererMixin.java b/src/main/java/net/dragonloot/mixin/client/HeadFeatureRendererMixin.java index 61775eb..c5a418b 100644 --- a/src/main/java/net/dragonloot/mixin/client/HeadFeatureRendererMixin.java +++ b/src/main/java/net/dragonloot/mixin/client/HeadFeatureRendererMixin.java @@ -48,8 +48,8 @@ private void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsum ((ModelWithHead) ((HeadFeatureRenderer) (Object) this).getContextModel()).getHead().rotate(matrixStack); matrixStack.translate(0.0D, -1.75D, 0.0D); matrixStack.scale(1.19F, 1.19F, 1.19F); - VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumerProvider, this.dragonHelmetModel.getLayer(new Identifier("dragonloot", "textures/entity/dragon_helmet_3d.png")), false, itemStack.hasGlint()); - this.dragonHelmetModel.render(matrixStack, vertexConsumer, i, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F); + VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumerProvider, this.dragonHelmetModel.getLayer(Identifier.of("dragonloot", "textures/entity/dragon_helmet_3d.png")), false); + this.dragonHelmetModel.render(matrixStack, vertexConsumer, i, OverlayTexture.DEFAULT_UV); matrixStack.pop(); info.cancel(); } diff --git a/src/main/java/net/dragonloot/mixin/client/HeldItemRendererMixin.java b/src/main/java/net/dragonloot/mixin/client/HeldItemRendererMixin.java index e65e169..8b8067c 100644 --- a/src/main/java/net/dragonloot/mixin/client/HeldItemRendererMixin.java +++ b/src/main/java/net/dragonloot/mixin/client/HeldItemRendererMixin.java @@ -13,7 +13,6 @@ import net.fabricmc.api.Environment; import net.dragonloot.init.ItemInit; -import net.dragonloot.item.DragonCrossbowItem; import net.fabricmc.api.EnvType; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.AbstractClientPlayerEntity; @@ -94,7 +93,7 @@ public HeldItemRendererMixin(MinecraftClient client) { @Inject(method = "renderFirstPersonItem", at = @At(value = "HEAD"), cancellable = true) private void renderFirstPersonItemMixin(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo info) { - if (item.getItem() == ItemInit.DRAGON_CROSSBOW_ITEM) { + if (item.getItem() == ItemInit.DRAGON_CROSSBOW) { matrices.push(); boolean bl = hand == Hand.MAIN_HAND; @@ -112,8 +111,8 @@ private void renderFirstPersonItemMixin(AbstractClientPlayerEntity player, float matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-11.935F)); matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees((float) i * 65.3F)); matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees((float) i * -9.785F)); - v = (float) item.getMaxUseTime() - ((float) this.client.player.getItemUseTimeLeft() - tickDelta + 1.0F); - w = v / (float) CrossbowItem.getPullTime(item); + v = (float) item.getMaxUseTime(player) - ((float) this.client.player.getItemUseTimeLeft() - tickDelta + 1.0F); + w = v / (float) CrossbowItem.getPullTime(item, player); if (w > 1.0F) { w = 1.0F; diff --git a/src/main/java/net/dragonloot/mixin/client/ItemRendererMixin.java b/src/main/java/net/dragonloot/mixin/client/ItemRendererMixin.java index ed2041c..e39a23a 100644 --- a/src/main/java/net/dragonloot/mixin/client/ItemRendererMixin.java +++ b/src/main/java/net/dragonloot/mixin/client/ItemRendererMixin.java @@ -28,6 +28,7 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.Identifier; import net.minecraft.world.World; @Environment(EnvType.CLIENT) @@ -42,16 +43,16 @@ public ItemRendererMixin(BakedModelManager baker) { @Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V", at = @At(value = "HEAD"), cancellable = true) public void renderItem(ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, CallbackInfo ci) { - if (!stack.isEmpty() && stack.getItem() == ItemInit.DRAGON_TRIDENT_ITEM) { + if (!stack.isEmpty() && stack.getItem() == ItemInit.DRAGON_TRIDENT) { matrices.push(); boolean bl = renderMode == ModelTransformationMode.GUI || renderMode == ModelTransformationMode.GROUND || renderMode == ModelTransformationMode.FIXED; - if (stack.getItem() == ItemInit.DRAGON_TRIDENT_ITEM && bl) { - model = ((ItemRendererAccess) this).getModelsInvoker().getModelManager().getModel(new ModelIdentifier("dragonloot", "dragon_trident", "inventory")); + if (stack.getItem() == ItemInit.DRAGON_TRIDENT && bl) { + model = ((ItemRendererAccess) this).getModelsInvoker().getModelManager().getModel(ModelIdentifier.ofInventoryVariant(Identifier.of("dragonloot", "dragon_trident"))); } model.getTransformation().getTransformation(renderMode).apply(leftHanded, matrices); matrices.translate(-0.5D, -0.5D, -0.5D); - if (model.isBuiltin() || stack.getItem() == ItemInit.DRAGON_TRIDENT_ITEM && !bl) { + if (model.isBuiltin() || stack.getItem() == ItemInit.DRAGON_TRIDENT && !bl) { DragonTridentItemRenderer.render(stack, renderMode, matrices, vertexConsumers, light, overlay); } else { RenderLayer renderLayer = RenderLayers.getItemLayer(stack, true); @@ -70,7 +71,7 @@ public void renderItem(ItemStack stack, ModelTransformationMode renderMode, bool public void getHeldItemModelMixin(ItemStack stack, @Nullable World world, @Nullable LivingEntity entity, int seed, CallbackInfoReturnable info) { Item item = stack.getItem(); BakedModel bakedModel2; - if (item == ItemInit.DRAGON_TRIDENT_ITEM) { + if (item == ItemInit.DRAGON_TRIDENT) { bakedModel2 = this.models.getModelManager().getModel(ItemRenderer.TRIDENT_IN_HAND); ClientWorld clientWorld = world instanceof ClientWorld ? (ClientWorld) world : null; BakedModel bakedModel3 = bakedModel2.getOverrides().apply(bakedModel2, stack, clientWorld, entity, seed); diff --git a/src/main/java/net/dragonloot/mixin/client/PlayerEntityRendererMixin.java b/src/main/java/net/dragonloot/mixin/client/PlayerEntityRendererMixin.java index 726cebe..e0300bc 100644 --- a/src/main/java/net/dragonloot/mixin/client/PlayerEntityRendererMixin.java +++ b/src/main/java/net/dragonloot/mixin/client/PlayerEntityRendererMixin.java @@ -28,7 +28,7 @@ public PlayerEntityRendererMixin(EntityRendererFactory.Context ctx, PlayerEntity @Inject(method = "getArmPose", at = @At("HEAD"), cancellable = true) private static void getArmPoseMixin(AbstractClientPlayerEntity abstractClientPlayerEntity, Hand hand, CallbackInfoReturnable info) { ItemStack itemStack = abstractClientPlayerEntity.getStackInHand(hand); - if (!abstractClientPlayerEntity.handSwinging && itemStack.getItem() == ItemInit.DRAGON_CROSSBOW_ITEM && CrossbowItem.isCharged(itemStack)) { + if (!abstractClientPlayerEntity.handSwinging && itemStack.getItem() == ItemInit.DRAGON_CROSSBOW && CrossbowItem.isCharged(itemStack)) { info.setReturnValue(BipedEntityModel.ArmPose.CROSSBOW_HOLD); } } diff --git a/src/main/java/net/dragonloot/network/DragonLootClientPacket.java b/src/main/java/net/dragonloot/network/DragonLootClientPacket.java new file mode 100644 index 0000000..bcb0bfd --- /dev/null +++ b/src/main/java/net/dragonloot/network/DragonLootClientPacket.java @@ -0,0 +1,26 @@ +package net.dragonloot.network; + +import net.dragonloot.access.DragonAnvilInterface; +import net.dragonloot.network.packet.AnvilPacket; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.screen.AnvilScreenHandler; + +public class DragonLootClientPacket { + + public static void init() { + ClientPlayNetworking.registerGlobalReceiver(AnvilPacket.PACKET_ID, (payload, context) -> { + int entityId = payload.entityId(); + String blockString = payload.blockString(); + context.client().execute(() -> { + if (context.player().getWorld().getEntityById(entityId) instanceof PlayerEntity playerEntity) { + if (playerEntity.currentScreenHandler instanceof AnvilScreenHandler) { + ((DragonAnvilInterface) playerEntity.currentScreenHandler).setDragonAnvil(blockString); + } + + } + }); + }); + } + +} diff --git a/src/main/java/net/dragonloot/network/DragonLootServerPacket.java b/src/main/java/net/dragonloot/network/DragonLootServerPacket.java new file mode 100644 index 0000000..c97f354 --- /dev/null +++ b/src/main/java/net/dragonloot/network/DragonLootServerPacket.java @@ -0,0 +1,11 @@ +package net.dragonloot.network; + +import net.dragonloot.network.packet.AnvilPacket; +import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; + +public class DragonLootServerPacket { + + public static void init() { + PayloadTypeRegistry.playS2C().register(AnvilPacket.PACKET_ID, AnvilPacket.PACKET_CODEC); + } +} diff --git a/src/main/java/net/dragonloot/network/SyncPacket.java b/src/main/java/net/dragonloot/network/SyncPacket.java deleted file mode 100644 index 8e3cd24..0000000 --- a/src/main/java/net/dragonloot/network/SyncPacket.java +++ /dev/null @@ -1,28 +0,0 @@ -package net.dragonloot.network; - -import net.dragonloot.access.DragonAnvilInterface; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.screen.AnvilScreenHandler; -import net.minecraft.util.Identifier; - -public class SyncPacket { - public static final Identifier ANVIL_SYNC_PACKET = new Identifier("dragonloot", "dragon_anvil_sync"); - - public static void init() { - ClientPlayNetworking.registerGlobalReceiver(ANVIL_SYNC_PACKET, (client, handler, buffer, responseSender) -> { - int entityId = buffer.readInt(); - String blockString = buffer.readString(); - client.execute(() -> { - if (client.player.getWorld().getEntityById(entityId) != null) { - PlayerEntity player = (PlayerEntity) client.player.getWorld().getEntityById(entityId); - if (player.currentScreenHandler instanceof AnvilScreenHandler) { - ((DragonAnvilInterface) player.currentScreenHandler).setDragonAnvil(blockString); - } - - } - }); - }); - - } -} diff --git a/src/main/java/net/dragonloot/network/packet/AnvilPacket.java b/src/main/java/net/dragonloot/network/packet/AnvilPacket.java new file mode 100644 index 0000000..ee7e067 --- /dev/null +++ b/src/main/java/net/dragonloot/network/packet/AnvilPacket.java @@ -0,0 +1,22 @@ +package net.dragonloot.network.packet; + +import net.minecraft.network.RegistryByteBuf; +import net.minecraft.network.codec.PacketCodec; +import net.minecraft.network.packet.CustomPayload; +import net.minecraft.util.Identifier; + +public record AnvilPacket(int entityId, String blockString) implements CustomPayload { + + public static final CustomPayload.Id PACKET_ID = new CustomPayload.Id<>(Identifier.of("dragonloot", "anvil_packet")); + + public static final PacketCodec PACKET_CODEC = PacketCodec.of((value, buf) -> { + buf.writeInt(value.entityId); + buf.writeString(value.blockString); + }, buf -> new AnvilPacket(buf.readInt(), buf.readString())); + + @Override + public Id getId() { + return PACKET_ID; + } + +} diff --git a/src/main/resources/assets/dragonloot/lang/en_us.json b/src/main/resources/assets/dragonloot/lang/en_us.json index 1922499..8761881 100644 --- a/src/main/resources/assets/dragonloot/lang/en_us.json +++ b/src/main/resources/assets/dragonloot/lang/en_us.json @@ -37,6 +37,7 @@ "text.autoconfig.dragonloot.option.dragon_armor_toughness": "Dragon Armor Toughness", "text.autoconfig.dragonloot.option.dragon_armor_knockback_resistance": "Dragon Armor Knockback Resistance", "text.autoconfig.dragonloot.option.dragon_armor_enchantability": "Dragon Armor Enchantability", + "text.autoconfig.dragonloot.option.dragon_item_mining_speed_multiplier": "Dragon Item Mining Speed Multiplier", "dragonloot.advancements.dragon_armor.title": "From the scales of the beast", "dragonloot.advancements.dragon_armor.description": "Get a full suit of Dragon armor" diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/armor/horse_armor_dragon.png b/src/main/resources/assets/dragonloot/textures/entity/horse/armor/horse_armor_dragon.png similarity index 100% rename from src/main/resources/assets/minecraft/textures/entity/horse/armor/horse_armor_dragon.png rename to src/main/resources/assets/dragonloot/textures/entity/horse/armor/horse_armor_dragon.png diff --git a/src/main/resources/assets/minecraft/textures/models/armor/dragon_layer_1.png b/src/main/resources/assets/dragonloot/textures/models/armor/dragon_layer_1.png similarity index 100% rename from src/main/resources/assets/minecraft/textures/models/armor/dragon_layer_1.png rename to src/main/resources/assets/dragonloot/textures/models/armor/dragon_layer_1.png diff --git a/src/main/resources/assets/minecraft/textures/models/armor/dragon_layer_2.png b/src/main/resources/assets/dragonloot/textures/models/armor/dragon_layer_2.png similarity index 100% rename from src/main/resources/assets/minecraft/textures/models/armor/dragon_layer_2.png rename to src/main/resources/assets/dragonloot/textures/models/armor/dragon_layer_2.png diff --git a/src/main/resources/data/c/tags/items/axes.json b/src/main/resources/data/c/tags/item/axes.json similarity index 100% rename from src/main/resources/data/c/tags/items/axes.json rename to src/main/resources/data/c/tags/item/axes.json diff --git a/src/main/resources/data/c/tags/items/hoes.json b/src/main/resources/data/c/tags/item/hoes.json similarity index 100% rename from src/main/resources/data/c/tags/items/hoes.json rename to src/main/resources/data/c/tags/item/hoes.json diff --git a/src/main/resources/data/c/tags/items/pickaxes.json b/src/main/resources/data/c/tags/item/pickaxes.json similarity index 100% rename from src/main/resources/data/c/tags/items/pickaxes.json rename to src/main/resources/data/c/tags/item/pickaxes.json diff --git a/src/main/resources/data/c/tags/items/shovels.json b/src/main/resources/data/c/tags/item/shovels.json similarity index 100% rename from src/main/resources/data/c/tags/items/shovels.json rename to src/main/resources/data/c/tags/item/shovels.json diff --git a/src/main/resources/data/c/tags/items/swords.json b/src/main/resources/data/c/tags/item/swords.json similarity index 100% rename from src/main/resources/data/c/tags/items/swords.json rename to src/main/resources/data/c/tags/item/swords.json diff --git a/src/main/resources/data/dragonloot/advancements/dragon_armor.json b/src/main/resources/data/dragonloot/advancement/dragon_armor.json similarity index 96% rename from src/main/resources/data/dragonloot/advancements/dragon_armor.json rename to src/main/resources/data/dragonloot/advancement/dragon_armor.json index f5839bc..7f53481 100644 --- a/src/main/resources/data/dragonloot/advancements/dragon_armor.json +++ b/src/main/resources/data/dragonloot/advancement/dragon_armor.json @@ -2,7 +2,7 @@ "parent": "minecraft:nether/netherite_armor", "display": { "icon": { - "item": "dragonloot:dragon_chestplate", + "id": "dragonloot:dragon_chestplate", "nbt": "{Damage:0}" }, "title": { diff --git a/src/main/resources/data/dragonloot/advancements/dragon_recipes.json b/src/main/resources/data/dragonloot/advancement/dragon_recipes.json similarity index 100% rename from src/main/resources/data/dragonloot/advancements/dragon_recipes.json rename to src/main/resources/data/dragonloot/advancement/dragon_recipes.json diff --git a/src/main/resources/data/dragonloot/loot_tables/blocks/dragon_anvil.json b/src/main/resources/data/dragonloot/loot_table/blocks/dragon_anvil.json similarity index 100% rename from src/main/resources/data/dragonloot/loot_tables/blocks/dragon_anvil.json rename to src/main/resources/data/dragonloot/loot_table/blocks/dragon_anvil.json diff --git a/src/main/resources/data/dragonloot/recipes/dragon_anvil.json b/src/main/resources/data/dragonloot/recipe/dragon_anvil.json similarity index 86% rename from src/main/resources/data/dragonloot/recipes/dragon_anvil.json rename to src/main/resources/data/dragonloot/recipe/dragon_anvil.json index 7befa7e..12979bc 100644 --- a/src/main/resources/data/dragonloot/recipes/dragon_anvil.json +++ b/src/main/resources/data/dragonloot/recipe/dragon_anvil.json @@ -7,7 +7,7 @@ "item": "dragonloot:dragon_scale" }, "result": { - "item": "dragonloot:dragon_anvil" + "id": "dragonloot:dragon_anvil" }, "template": { "item": "minecraft:netherite_upgrade_smithing_template" diff --git a/src/main/resources/data/dragonloot/recipes/dragon_axe.json b/src/main/resources/data/dragonloot/recipe/dragon_axe.json similarity index 87% rename from src/main/resources/data/dragonloot/recipes/dragon_axe.json rename to src/main/resources/data/dragonloot/recipe/dragon_axe.json index 1e50b19..2152d89 100644 --- a/src/main/resources/data/dragonloot/recipes/dragon_axe.json +++ b/src/main/resources/data/dragonloot/recipe/dragon_axe.json @@ -7,7 +7,7 @@ "item": "dragonloot:dragon_scale" }, "result": { - "item": "dragonloot:dragon_axe" + "id": "dragonloot:dragon_axe" }, "template": { "item": "minecraft:netherite_upgrade_smithing_template" diff --git a/src/main/resources/data/dragonloot/recipes/dragon_boots.json b/src/main/resources/data/dragonloot/recipe/dragon_boots.json similarity index 87% rename from src/main/resources/data/dragonloot/recipes/dragon_boots.json rename to src/main/resources/data/dragonloot/recipe/dragon_boots.json index 4619282..edb3221 100644 --- a/src/main/resources/data/dragonloot/recipes/dragon_boots.json +++ b/src/main/resources/data/dragonloot/recipe/dragon_boots.json @@ -7,7 +7,7 @@ "item": "dragonloot:dragon_scale" }, "result": { - "item": "dragonloot:dragon_boots" + "id": "dragonloot:dragon_boots" }, "template": { "item": "minecraft:netherite_upgrade_smithing_template" diff --git a/src/main/resources/data/dragonloot/recipes/dragon_chestplate.json b/src/main/resources/data/dragonloot/recipe/dragon_chestplate.json similarity index 86% rename from src/main/resources/data/dragonloot/recipes/dragon_chestplate.json rename to src/main/resources/data/dragonloot/recipe/dragon_chestplate.json index 89dfb2d..ada9696 100644 --- a/src/main/resources/data/dragonloot/recipes/dragon_chestplate.json +++ b/src/main/resources/data/dragonloot/recipe/dragon_chestplate.json @@ -7,7 +7,7 @@ "item": "dragonloot:dragon_scale" }, "result": { - "item": "dragonloot:dragon_chestplate" + "id": "dragonloot:dragon_chestplate" }, "template": { "item": "minecraft:netherite_upgrade_smithing_template" diff --git a/src/main/resources/data/dragonloot/recipes/dragon_helmet.json b/src/main/resources/data/dragonloot/recipe/dragon_helmet.json similarity index 87% rename from src/main/resources/data/dragonloot/recipes/dragon_helmet.json rename to src/main/resources/data/dragonloot/recipe/dragon_helmet.json index c860a56..8c669ac 100644 --- a/src/main/resources/data/dragonloot/recipes/dragon_helmet.json +++ b/src/main/resources/data/dragonloot/recipe/dragon_helmet.json @@ -7,7 +7,7 @@ "item": "dragonloot:dragon_scale" }, "result": { - "item": "dragonloot:dragon_helmet" + "id": "dragonloot:dragon_helmet" }, "template": { "item": "minecraft:netherite_upgrade_smithing_template" diff --git a/src/main/resources/data/dragonloot/recipes/dragon_hoe.json b/src/main/resources/data/dragonloot/recipe/dragon_hoe.json similarity index 87% rename from src/main/resources/data/dragonloot/recipes/dragon_hoe.json rename to src/main/resources/data/dragonloot/recipe/dragon_hoe.json index e7bc9b5..7684846 100644 --- a/src/main/resources/data/dragonloot/recipes/dragon_hoe.json +++ b/src/main/resources/data/dragonloot/recipe/dragon_hoe.json @@ -7,7 +7,7 @@ "item": "dragonloot:dragon_scale" }, "result": { - "item": "dragonloot:dragon_hoe" + "id": "dragonloot:dragon_hoe" }, "template": { "item": "minecraft:netherite_upgrade_smithing_template" diff --git a/src/main/resources/data/dragonloot/recipes/dragon_leggings.json b/src/main/resources/data/dragonloot/recipe/dragon_leggings.json similarity index 86% rename from src/main/resources/data/dragonloot/recipes/dragon_leggings.json rename to src/main/resources/data/dragonloot/recipe/dragon_leggings.json index 59a1db0..940aefb 100644 --- a/src/main/resources/data/dragonloot/recipes/dragon_leggings.json +++ b/src/main/resources/data/dragonloot/recipe/dragon_leggings.json @@ -7,7 +7,7 @@ "item": "dragonloot:dragon_scale" }, "result": { - "item": "dragonloot:dragon_leggings" + "id": "dragonloot:dragon_leggings" }, "template": { "item": "minecraft:netherite_upgrade_smithing_template" diff --git a/src/main/resources/data/dragonloot/recipes/dragon_pickaxe.json b/src/main/resources/data/dragonloot/recipe/dragon_pickaxe.json similarity index 86% rename from src/main/resources/data/dragonloot/recipes/dragon_pickaxe.json rename to src/main/resources/data/dragonloot/recipe/dragon_pickaxe.json index beb0fed..8245266 100644 --- a/src/main/resources/data/dragonloot/recipes/dragon_pickaxe.json +++ b/src/main/resources/data/dragonloot/recipe/dragon_pickaxe.json @@ -7,7 +7,7 @@ "item": "dragonloot:dragon_scale" }, "result": { - "item": "dragonloot:dragon_pickaxe" + "id": "dragonloot:dragon_pickaxe" }, "template": { "item": "minecraft:netherite_upgrade_smithing_template" diff --git a/src/main/resources/data/dragonloot/recipes/dragon_shovel.json b/src/main/resources/data/dragonloot/recipe/dragon_shovel.json similarity index 87% rename from src/main/resources/data/dragonloot/recipes/dragon_shovel.json rename to src/main/resources/data/dragonloot/recipe/dragon_shovel.json index d68eb48..28619d2 100644 --- a/src/main/resources/data/dragonloot/recipes/dragon_shovel.json +++ b/src/main/resources/data/dragonloot/recipe/dragon_shovel.json @@ -7,7 +7,7 @@ "item": "dragonloot:dragon_scale" }, "result": { - "item": "dragonloot:dragon_shovel" + "id": "dragonloot:dragon_shovel" }, "template": { "item": "minecraft:netherite_upgrade_smithing_template" diff --git a/src/main/resources/data/dragonloot/recipes/dragon_sword.json b/src/main/resources/data/dragonloot/recipe/dragon_sword.json similarity index 87% rename from src/main/resources/data/dragonloot/recipes/dragon_sword.json rename to src/main/resources/data/dragonloot/recipe/dragon_sword.json index 5b36da2..802ebfa 100644 --- a/src/main/resources/data/dragonloot/recipes/dragon_sword.json +++ b/src/main/resources/data/dragonloot/recipe/dragon_sword.json @@ -7,7 +7,7 @@ "item": "dragonloot:dragon_scale" }, "result": { - "item": "dragonloot:dragon_sword" + "id": "dragonloot:dragon_sword" }, "template": { "item": "minecraft:netherite_upgrade_smithing_template" diff --git a/src/main/resources/data/dragonloot/tags/items/explosion_resistant.json b/src/main/resources/data/dragonloot/tags/item/explosion_resistant.json similarity index 100% rename from src/main/resources/data/dragonloot/tags/items/explosion_resistant.json rename to src/main/resources/data/dragonloot/tags/item/explosion_resistant.json diff --git a/src/main/resources/data/fabric/tags/items/axes.json b/src/main/resources/data/fabric/tags/item/axes.json similarity index 100% rename from src/main/resources/data/fabric/tags/items/axes.json rename to src/main/resources/data/fabric/tags/item/axes.json diff --git a/src/main/resources/data/fabric/tags/items/hoes.json b/src/main/resources/data/fabric/tags/item/hoes.json similarity index 100% rename from src/main/resources/data/fabric/tags/items/hoes.json rename to src/main/resources/data/fabric/tags/item/hoes.json diff --git a/src/main/resources/data/fabric/tags/items/pickaxes.json b/src/main/resources/data/fabric/tags/item/pickaxes.json similarity index 100% rename from src/main/resources/data/fabric/tags/items/pickaxes.json rename to src/main/resources/data/fabric/tags/item/pickaxes.json diff --git a/src/main/resources/data/fabric/tags/items/shovels.json b/src/main/resources/data/fabric/tags/item/shovels.json similarity index 100% rename from src/main/resources/data/fabric/tags/items/shovels.json rename to src/main/resources/data/fabric/tags/item/shovels.json diff --git a/src/main/resources/data/fabric/tags/items/swords.json b/src/main/resources/data/fabric/tags/item/swords.json similarity index 100% rename from src/main/resources/data/fabric/tags/items/swords.json rename to src/main/resources/data/fabric/tags/item/swords.json diff --git a/src/main/resources/data/minecraft/tags/blocks/anvil.json b/src/main/resources/data/minecraft/tags/block/anvil.json similarity index 100% rename from src/main/resources/data/minecraft/tags/blocks/anvil.json rename to src/main/resources/data/minecraft/tags/block/anvil.json diff --git a/src/main/resources/data/minecraft/tags/items/cluster_max_harvestables.json b/src/main/resources/data/minecraft/tags/item/cluster_max_harvestables.json similarity index 100% rename from src/main/resources/data/minecraft/tags/items/cluster_max_harvestables.json rename to src/main/resources/data/minecraft/tags/item/cluster_max_harvestables.json diff --git a/src/main/resources/data/silky_spawners/tags/items/allowed_tools.json b/src/main/resources/data/silky_spawners/tags/item/allowed_tools.json similarity index 100% rename from src/main/resources/data/silky_spawners/tags/items/allowed_tools.json rename to src/main/resources/data/silky_spawners/tags/item/allowed_tools.json diff --git a/src/main/resources/data/stuffz/uncraft_recipes/dragon_axe.json b/src/main/resources/data/stuffz/uncraft_recipes/dragon_axe.json deleted file mode 100644 index aec8d20..0000000 --- a/src/main/resources/data/stuffz/uncraft_recipes/dragon_axe.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "item": "dragonloot:dragon_axe", - "result": "dragonloot:dragon_scale", - "count": 1 -} \ No newline at end of file diff --git a/src/main/resources/data/stuffz/uncraft_recipes/dragon_boots.json b/src/main/resources/data/stuffz/uncraft_recipes/dragon_boots.json deleted file mode 100644 index b25a59a..0000000 --- a/src/main/resources/data/stuffz/uncraft_recipes/dragon_boots.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "item": "dragonloot:dragon_boots", - "result": "dragonloot:dragon_scale", - "count": 1 -} \ No newline at end of file diff --git a/src/main/resources/data/stuffz/uncraft_recipes/dragon_bow.json b/src/main/resources/data/stuffz/uncraft_recipes/dragon_bow.json deleted file mode 100644 index 3a3bf60..0000000 --- a/src/main/resources/data/stuffz/uncraft_recipes/dragon_bow.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "item": "dragonloot:dragon_bow", - "result": "dragonloot:dragon_scale", - "count": 1 -} \ No newline at end of file diff --git a/src/main/resources/data/stuffz/uncraft_recipes/dragon_chestplate.json b/src/main/resources/data/stuffz/uncraft_recipes/dragon_chestplate.json deleted file mode 100644 index eef8b84..0000000 --- a/src/main/resources/data/stuffz/uncraft_recipes/dragon_chestplate.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "item": "dragonloot:dragon_chestplate", - "result": "dragonloot:dragon_scale", - "count": 1 -} \ No newline at end of file diff --git a/src/main/resources/data/stuffz/uncraft_recipes/dragon_crossbow.json b/src/main/resources/data/stuffz/uncraft_recipes/dragon_crossbow.json deleted file mode 100644 index 4862c4d..0000000 --- a/src/main/resources/data/stuffz/uncraft_recipes/dragon_crossbow.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "item": "dragonloot:dragon_crossbow", - "result": "dragonloot:dragon_scale", - "count": 1 -} \ No newline at end of file diff --git a/src/main/resources/data/stuffz/uncraft_recipes/dragon_helmet.json b/src/main/resources/data/stuffz/uncraft_recipes/dragon_helmet.json deleted file mode 100644 index 4fadd7b..0000000 --- a/src/main/resources/data/stuffz/uncraft_recipes/dragon_helmet.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "item": "dragonloot:dragon_helmet", - "result": "dragonloot:dragon_scale", - "count": 1 -} \ No newline at end of file diff --git a/src/main/resources/data/stuffz/uncraft_recipes/dragon_hoe.json b/src/main/resources/data/stuffz/uncraft_recipes/dragon_hoe.json deleted file mode 100644 index ddc141d..0000000 --- a/src/main/resources/data/stuffz/uncraft_recipes/dragon_hoe.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "item": "dragonloot:dragon_hoe", - "result": "dragonloot:dragon_scale", - "count": 1 -} \ No newline at end of file diff --git a/src/main/resources/data/stuffz/uncraft_recipes/dragon_horse_armor.json b/src/main/resources/data/stuffz/uncraft_recipes/dragon_horse_armor.json deleted file mode 100644 index e4ff6d3..0000000 --- a/src/main/resources/data/stuffz/uncraft_recipes/dragon_horse_armor.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "item": "dragonloot:dragon_horse_armor", - "result": "dragonloot:dragon_scale", - "count": 1 -} \ No newline at end of file diff --git a/src/main/resources/data/stuffz/uncraft_recipes/dragon_leggings.json b/src/main/resources/data/stuffz/uncraft_recipes/dragon_leggings.json deleted file mode 100644 index 00c221d..0000000 --- a/src/main/resources/data/stuffz/uncraft_recipes/dragon_leggings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "item": "dragonloot:dragon_leggings", - "result": "dragonloot:dragon_scale", - "count": 1 -} \ No newline at end of file diff --git a/src/main/resources/data/stuffz/uncraft_recipes/dragon_pickaxe.json b/src/main/resources/data/stuffz/uncraft_recipes/dragon_pickaxe.json deleted file mode 100644 index 1ba05b3..0000000 --- a/src/main/resources/data/stuffz/uncraft_recipes/dragon_pickaxe.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "item": "dragonloot:dragon_pickaxe", - "result": "dragonloot:dragon_scale", - "count": 1 -} \ No newline at end of file diff --git a/src/main/resources/data/stuffz/uncraft_recipes/dragon_shovel.json b/src/main/resources/data/stuffz/uncraft_recipes/dragon_shovel.json deleted file mode 100644 index e7ed43c..0000000 --- a/src/main/resources/data/stuffz/uncraft_recipes/dragon_shovel.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "item": "dragonloot:dragon_shovel", - "result": "dragonloot:dragon_scale", - "count": 1 -} \ No newline at end of file diff --git a/src/main/resources/data/stuffz/uncraft_recipes/dragon_sword.json b/src/main/resources/data/stuffz/uncraft_recipes/dragon_sword.json deleted file mode 100644 index 421ab90..0000000 --- a/src/main/resources/data/stuffz/uncraft_recipes/dragon_sword.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "item": "dragonloot:dragon_sword", - "result": "dragonloot:dragon_scale", - "count": 1 -} \ No newline at end of file diff --git a/src/main/resources/data/stuffz/uncraft_recipes/dragon_trident.json b/src/main/resources/data/stuffz/uncraft_recipes/dragon_trident.json deleted file mode 100644 index 58eed38..0000000 --- a/src/main/resources/data/stuffz/uncraft_recipes/dragon_trident.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "item": "dragonloot:dragon_trident", - "result": "dragonloot:dragon_scale", - "count": 1 -} \ No newline at end of file diff --git a/src/main/resources/data/stuffz/uncraft_recipes/upgraded_dragon_chestplate.json b/src/main/resources/data/stuffz/uncraft_recipes/upgraded_dragon_chestplate.json deleted file mode 100644 index f1050f6..0000000 --- a/src/main/resources/data/stuffz/uncraft_recipes/upgraded_dragon_chestplate.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "item": "dragonloot:upgraded_dragon_chestplate", - "result": "dragonloot:dragon_scale", - "count": 1 -} \ No newline at end of file diff --git a/src/main/resources/data/tooltiprareness/tags/items/epic_item.json b/src/main/resources/data/tooltiprareness/tags/item/epic_item.json similarity index 100% rename from src/main/resources/data/tooltiprareness/tags/items/epic_item.json rename to src/main/resources/data/tooltiprareness/tags/item/epic_item.json diff --git a/src/main/resources/dragonloot.aw b/src/main/resources/dragonloot.aw index 1d8bdc8..a65ceff 100644 --- a/src/main/resources/dragonloot.aw +++ b/src/main/resources/dragonloot.aw @@ -3,7 +3,5 @@ accessWidener v1 named accessible method net/minecraft/screen/AnvilScreenHandler onTakeOutput (Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/item/ItemStack;)V accessible method net/minecraft/screen/AnvilScreenHandler canUse (Lnet/minecraft/block/BlockState;)Z -accessible field net/minecraft/entity/projectile/TridentEntity tridentStack Lnet/minecraft/item/ItemStack; -accessible field net/minecraft/item/TridentItem attributeModifiers Lcom/google/common/collect/Multimap; mutable field net/minecraft/entity/attribute/EntityAttributeModifier value D accessible field net/minecraft/entity/attribute/EntityAttributeModifier value D \ No newline at end of file diff --git a/src/main/resources/dragonloot.mixins.json b/src/main/resources/dragonloot.mixins.json index 8de47e0..55ef834 100644 --- a/src/main/resources/dragonloot.mixins.json +++ b/src/main/resources/dragonloot.mixins.json @@ -2,17 +2,15 @@ "required": true, "minVersion": "0.8", "package": "net.dragonloot.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", "mixins": [ "AnvilBlockMixin", "AnvilScreenHandlerMixin", - "BowItemMixin", - "CrossbowItemMixin", + "RangedWeaponItemMixin", "EnderDragonEntityMixin", "ItemEntityMixin", "LivingEntityMixin", "PlayerEntityMixin", - "PlayerInventoryMixin", "RecipeManagerMixin" ], "client": [ diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 8dc1692..0ed9b8c 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -31,7 +31,7 @@ "dragonloot.mixins.json" ], "depends": { - "java": ">=17", + "java": ">=21", "minecraft": ">=${minecraft_version}", "fabric-api": ">=${fabric_version}", "fabricloader": ">=${loader_version}",