diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1e782c5..fdd9fb9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,26 +6,24 @@ jobs: strategy: matrix: java: [ 21 ] - os: [ ubuntu-22.04 ] - runs-on: ${{ matrix.os }} + runs-on: ubuntu-22.04 steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Validate gradle wrapper - uses: gradle/wrapper-validation-action@v1 + uses: gradle/wrapper-validation-action@v2 - name: Setup JDK ${{ matrix.java }} - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: ${{ matrix.java }} distribution: 'microsoft' - name: Make gradle wrapper executable - if: ${{ runner.os != 'Windows' }} run: chmod +x ./gradlew - name: build run: ./gradlew build - name: Capture build artifacts - if: ${{ runner.os == 'Linux' && matrix.java == '21' }} - uses: actions/upload-artifact@v3 + if: ${{ matrix.java == '21' }} + uses: actions/upload-artifact@v4 with: name: Artifacts path: build/libs/ diff --git a/.github/workflows/publish-curseforge.yml b/.github/workflows/publish-curseforge.yml deleted file mode 100644 index 05bddf0..0000000 --- a/.github/workflows/publish-curseforge.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: publish-curseforge - -on: - release: - types: - - published - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - distribution: 'adopt-hotspot' - java-version: '21' - - name: Change wrapper permissions - run: chmod +x ./gradlew - - name: Build artifacts - run: ./gradlew build - - uses: BrycensRanch/read-properties-action@v1 - id: gradle_props - with: - file: gradle.properties - all: true - - name: Publish fabric artifacts - uses: Kir-Antipov/mc-publish@v3.3.0 - with: - curseforge-id: 521126 - curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} - - files: | - build/libs/${{ steps.gradle_props.outputs.archives_base_name }}-${{ github.event.release.tag_name }}.jar - build/libs/${{ steps.gradle_props.outputs.archives_base_name }}-${{ github.event.release.tag_name }}-sources.jar - - version: ${{ github.event.release.tag_name }} - - version-type: beta - loaders: | - fabric - quilt - - game-versions: ${{ steps.gradle_props.outputs.minecraft_version_range }} - game-version-filter: releases - - dependencies: | - fabric-api - cloth-config - - java: | - 21 - - retry-attempts: 2 - retry-delay: 10000 - fail-mode: skip \ No newline at end of file diff --git a/.github/workflows/publish-github.yml b/.github/workflows/publish-github.yml deleted file mode 100644 index 5e55d66..0000000 --- a/.github/workflows/publish-github.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: publish-github - -on: - release: - types: - - published - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - distribution: 'adopt-hotspot' - java-version: '21' - - name: Change wrapper permissions - run: chmod +x ./gradlew - - name: Build artifacts - run: ./gradlew build - - name: Upload assets to GitHub - uses: AButler/upload-release-assets@v3.0 - with: - files: "build/libs/*" - repo-token: ${{ secrets.GH_TOKEN }} diff --git a/.github/workflows/publish-modrinth.yml b/.github/workflows/publish-modrinth.yml deleted file mode 100644 index eff6bd5..0000000 --- a/.github/workflows/publish-modrinth.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: publish-modrinth - -on: - release: - types: - - published - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - distribution: 'adopt-hotspot' - java-version: '21' - - name: Change wrapper permissions - run: chmod +x ./gradlew - - name: Build artifacts - run: ./gradlew build - - uses: BrycensRanch/read-properties-action@v1 - id: gradle_props - with: - file: gradle.properties - all: true - - name: Publish fabric artifacts - uses: Kir-Antipov/mc-publish@v3.3.0 - with: - modrinth-id: rI0hvYcd - modrinth-token: ${{ secrets.MODRINTH_TOKEN }} - - files: | - build/libs/${{ steps.gradle_props.outputs.archives_base_name }}-${{ github.event.release.tag_name }}.jar - build/libs/${{ steps.gradle_props.outputs.archives_base_name }}-${{ github.event.release.tag_name }}-sources.jar - - version: ${{ github.event.release.tag_name }} - - version-type: beta - loaders: | - fabric - quilt - - game-versions: ${{ steps.gradle_props.outputs.minecraft_version_range }} - game-version-filter: releases - - dependencies: | - fabric-api - cloth-config - - java: | - 21 - - retry-attempts: 2 - retry-delay: 10000 - fail-mode: skip - - - name: Hit mod update webhook - uses: fjogeleit/http-request-action@v1 - with: - url: ${{ secrets.MOD_UPDATE_WEBHOOK }} - method: 'GET' - preventFailureOnNoResponse: 'true' diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..b3540b0 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,76 @@ +name: publish + +on: + release: + types: + - published + +jobs: + build: + strategy: + matrix: + java: [ 21 ] + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Validate gradle wrapper + uses: gradle/wrapper-validation-action@v2 + - name: Setup JDK ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java }} + distribution: 'microsoft' + - name: Make gradle wrapper executable + run: chmod +x ./gradlew + - name: Build + run: ./gradlew build + - uses: BrycensRanch/read-properties-action@v1 + id: props + with: + file: gradle.properties + all: true + + - name: Publish + uses: Kir-Antipov/mc-publish@v3.3.0 + with: + modrinth-id: ${{ steps.props.outputs.modrinth_id }} + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + curseforge-id: ${{ steps.props.outputs.curseforge_id }} + curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} + + files: | + build/libs/${{ steps.props.outputs.archives_base_name }}-${{ github.event.release.tag_name }}.jar + build/libs/${{ steps.props.outputs.archives_base_name }}-${{ github.event.release.tag_name }}-sources.jar + + version: ${{ github.event.release.tag_name }} + + version-type: beta + loaders: | + fabric + + game-versions: ${{ steps.props.outputs.minecraft_version_range }} + game-version-filter: releases + + dependencies: | + fabric-api + cloth-config + + java: | + 21 + + retry-attempts: 0 + fail-mode: skip + + - name: Upload assets to GitHub + uses: AButler/upload-release-assets@v3.0 + with: + files: "build/libs/*" + repo-token: ${{ secrets.GH_TOKEN }} + + - name: Hit mod update webhook + uses: fjogeleit/http-request-action@v1 + with: + url: ${{ secrets.MOD_UPDATE_WEBHOOK }} + method: 'GET' + preventFailureOnNoResponse: 'true' diff --git a/build.gradle b/build.gradle index 37bbf25..8cb22c6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id "fabric-loom" version "1.7-SNAPSHOT" + id "fabric-loom" version "1.8-SNAPSHOT" } version = project.mod_version diff --git a/gradle.properties b/gradle.properties index 858ba27..3d8b3c6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,16 +3,19 @@ org.gradle.jvmargs = -Xmx2G org.gradle.parallel = true # Mod Properties -mod_version = 0.7.7+1.21 +mod_version = 0.7.8+1.21.3 maven_group = ru.pinkgoosik archives_base_name = visuality -minecraft_version_range = >=1.21 <1.22 + +minecraft_version_range = >=1.21.2 <1.22 +modrinth_id = rI0hvYcd +curseforge_id = 521126 # Dependencies | Check these on https://fabricmc.net/develop -minecraft_version = 1.21 -yarn_mappings = 1.21+build.2 -fabric_loader = 0.15.11 -fabric_api = 0.100.3+1.21 +minecraft_version = 1.21.3 +yarn_mappings = 1.21.3+build.2 +fabric_loader = 0.16.8 +fabric_api = 0.107.0+1.21.3 -cloth_config = 15.0.127 -modmenu_version = 11.0.1 +cloth_config = 16.0.141 +modmenu_version = 12.0.0-beta.1 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2617362..707e499 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/visuality/config/VisualityClothConfig.java b/src/main/java/visuality/config/VisualityClothConfig.java index 5a898ee..9fffb27 100644 --- a/src/main/java/visuality/config/VisualityClothConfig.java +++ b/src/main/java/visuality/config/VisualityClothConfig.java @@ -81,6 +81,11 @@ private static void setupEntries(ConfigCategory category, ConfigEntryBuilder ent .setSaveConsumer(newValue -> config.hitParticlesEnabled = newValue) .build()); +// category.addEntry(entryBuilder.startFloatField(text("option.hitParticlesPer1Damage"), config.hitParticlesPer1Damage) +// .setDefaultValue(0.5F) +// .setSaveConsumer(newValue -> config.hitParticlesPer1Damage = newValue) +// .build()); + category.addEntry(entryBuilder.startStrList(text("option.hitParticles.entries"), config.hitParticleEntries) .setDefaultValue(VisualityConfig.DEFAULT_HIT_PARTICLES) .setSaveConsumer(newValue -> { diff --git a/src/main/java/visuality/config/VisualityConfig.java b/src/main/java/visuality/config/VisualityConfig.java index b75aff5..5b92025 100644 --- a/src/main/java/visuality/config/VisualityConfig.java +++ b/src/main/java/visuality/config/VisualityConfig.java @@ -29,6 +29,7 @@ public class VisualityConfig { public VisualityClothConfig.WaterCirclesConfigOption waterCircles = new VisualityClothConfig.WaterCirclesConfigOption(); public boolean hitParticlesEnabled = true; +// public float hitParticlesPer1Damage = 0.5F; public ArrayList hitParticleEntries = DEFAULT_HIT_PARTICLES; public boolean shinyArmorEnabled = true; diff --git a/src/main/java/visuality/event/CirclesOnWaterEvent.java b/src/main/java/visuality/event/CirclesOnWaterEvent.java index 0346e00..0c53cbe 100644 --- a/src/main/java/visuality/event/CirclesOnWaterEvent.java +++ b/src/main/java/visuality/event/CirclesOnWaterEvent.java @@ -3,8 +3,8 @@ import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.option.ParticlesMode; import net.minecraft.client.world.ClientWorld; +import net.minecraft.particle.ParticlesMode; import net.minecraft.util.math.BlockPos; import net.minecraft.world.Heightmap; import net.minecraft.world.World; @@ -36,7 +36,7 @@ public static void onTick(ClientWorld world) { BlockPos playerPos = new BlockPos((int) player.getX() + x, (int) player.getY(), (int) player.getZ() + z); BlockPos topPos = world.getTopPosition(Heightmap.Type.MOTION_BLOCKING, playerPos); - if(!(biome.getPrecipitation(topPos).equals(Biome.Precipitation.RAIN)) || !(biome.doesNotSnow(player.getSteppingPos()))) continue; + if(!(biome.getPrecipitation(topPos, world.getSeaLevel()).equals(Biome.Precipitation.RAIN)) || !(biome.doesNotSnow(player.getSteppingPos(), world.getSeaLevel()))) continue; if(world.getBlockState(topPos.down()).isOf(Blocks.WATER) && world.getBlockState(topPos).isAir()) { if(world.getFluidState(topPos.down()).getLevel() == 8) { ParticleUtils.add(world, VisualityParticles.WATER_CIRCLE, topPos.getX() + random.nextDouble(), topPos.getY() + 0.05D, topPos.getZ() + random.nextDouble()); diff --git a/src/main/java/visuality/mixin/BlockMixin.java b/src/main/java/visuality/mixin/BlockMixin.java index 18319e7..a9ff1bc 100644 --- a/src/main/java/visuality/mixin/BlockMixin.java +++ b/src/main/java/visuality/mixin/BlockMixin.java @@ -55,7 +55,7 @@ void randomDisplayTick(BlockState state, World world, BlockPos pos, Random rando if(VisualityMod.config.shinyBlocksEnabled && ShinyBlockRegistry.isShiny(state)) { for(Direction direction : Direction.values()) { BlockPos offset = pos.offset(direction); - if(!world.getBlockState(offset).isOpaqueFullCube(world, offset)) { + if(!world.getBlockState(offset).isOpaqueFullCube()) { if(random.nextFloat() > 0.8) { Direction.Axis axis = direction.getAxis(); double x = axis == Direction.Axis.X ? 0.5 + 0.5625 * (double) direction.getOffsetX() : (double) random.nextFloat(); diff --git a/src/main/java/visuality/mixin/LivingEntityMixin.java b/src/main/java/visuality/mixin/LivingEntityMixin.java index 18be4fe..2061cce 100644 --- a/src/main/java/visuality/mixin/LivingEntityMixin.java +++ b/src/main/java/visuality/mixin/LivingEntityMixin.java @@ -1,13 +1,13 @@ package visuality.mixin; import net.minecraft.client.MinecraftClient; +import net.minecraft.component.DataComponentTypes; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.damage.DamageSource; -import net.minecraft.item.Item; -import net.minecraft.item.MiningToolItem; -import net.minecraft.item.SwordItem; +import net.minecraft.item.ItemStack; import net.minecraft.particle.ParticleEffect; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; @@ -16,7 +16,6 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import visuality.VisualityMod; import visuality.registry.HitParticleRegistry; import visuality.registry.VisualityParticles; @@ -53,21 +52,29 @@ private void tick(CallbackInfo ci) { } } - @Inject(method = "damage", at = @At("HEAD")) - void damage(DamageSource source, float amount, CallbackInfoReturnable cir) { + @Override + public boolean clientDamage(DamageSource source) { if(getWorld().isClient() && source.getAttacker() instanceof LivingEntity attacker && ticksDelay == 0 && this.isAlive() && VisualityMod.config.hitParticlesEnabled) { HitParticleRegistry.ENTRIES.forEach(entry -> { if(this.getType().equals(entry.entity())) { ticksDelay = 10; - Item item = attacker.getMainHandStack().getItem(); - int count = this.random.nextInt(2); - if(item instanceof SwordItem sword) count = (int)sword.getMaterial().getAttackDamage() / 2; - else if(item instanceof MiningToolItem tool) - count = (int)tool.getMaterial().getAttackDamage() / 2; + ItemStack stack = attacker.getMainHandStack(); + int count = this.random.nextInt(3); + + if(stack.getComponents().contains(DataComponentTypes.ATTRIBUTE_MODIFIERS)) { + var data = stack.getComponents().get(DataComponentTypes.ATTRIBUTE_MODIFIERS); + for(var att : data.modifiers()) { + if(att.attribute().equals(EntityAttributes.ATTACK_DAMAGE)) { + count = (int)((float)att.modifier().value() * 0.5F); + } + } + } + spawnHitParticles(entry.particle(), count); } }); } + return super.clientDamage(source); } @Unique @@ -75,7 +82,7 @@ private void spawnHitParticles(ParticleEffect particle, int count) { float height = this.getHeight(); if(height * 100 < 100) height = 1.0F; else height = height + 0.5F; - for(int i = 0; i <= count; i++) { + for(int i = 0; i <= Math.min(count, 10); i++) { double randomHeight = (double) this.random.nextInt((int) height * 10) / 10; ParticleUtils.add(getWorld(), particle, this.getX(), this.getY() + 0.2D + randomHeight, this.getZ()); } diff --git a/src/main/java/visuality/particle/ChargeParticle.java b/src/main/java/visuality/particle/ChargeParticle.java index e16f3c5..f5508e6 100644 --- a/src/main/java/visuality/particle/ChargeParticle.java +++ b/src/main/java/visuality/particle/ChargeParticle.java @@ -28,7 +28,7 @@ public void tick() { @Override public ParticleTextureSheet getType() { - return ParticleTextureSheet.PARTICLE_SHEET_LIT; + return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; } public record Factory(SpriteProvider sprites) implements ParticleFactory { diff --git a/src/main/java/visuality/particle/SparkleParticle.java b/src/main/java/visuality/particle/SparkleParticle.java index a0a8952..97e59d4 100644 --- a/src/main/java/visuality/particle/SparkleParticle.java +++ b/src/main/java/visuality/particle/SparkleParticle.java @@ -28,7 +28,7 @@ public void tick() { @Override public ParticleTextureSheet getType() { - return ParticleTextureSheet.PARTICLE_SHEET_LIT; + return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; } @Override diff --git a/src/main/java/visuality/particle/WaterCircleParticle.java b/src/main/java/visuality/particle/WaterCircleParticle.java index 49935cd..e4d5da3 100644 --- a/src/main/java/visuality/particle/WaterCircleParticle.java +++ b/src/main/java/visuality/particle/WaterCircleParticle.java @@ -30,9 +30,9 @@ private WaterCircleParticle(ClientWorld world, double x, double y, double z, Spr public void setColor() { var waterColor = BiomeColors.getWaterColor(this.world, BlockPos.ofFloored(x, y, z)); - var red = ColorHelper.Argb.getRed(waterColor) / 255.0f; - var green = ColorHelper.Argb.getGreen(waterColor) / 255.0f; - var blue = ColorHelper.Argb.getBlue(waterColor) / 255.0f; + var red = ColorHelper.getRed(waterColor) / 255.0f; + var green = ColorHelper.getGreen(waterColor) / 255.0f; + var blue = ColorHelper.getBlue(waterColor) / 255.0f; this.setColor(red, green, blue); } diff --git a/src/main/java/visuality/registry/HitParticleRegistry.java b/src/main/java/visuality/registry/HitParticleRegistry.java index 9ddb01b..4c83264 100644 --- a/src/main/java/visuality/registry/HitParticleRegistry.java +++ b/src/main/java/visuality/registry/HitParticleRegistry.java @@ -29,11 +29,11 @@ public static void reload() { } private static Optional> getEntityFromString(String id) { - return Registries.ENTITY_TYPE.getOrEmpty(Identifier.of(id)); + return Registries.ENTITY_TYPE.getOptionalValue(Identifier.of(id)); } private static Optional> getParticleFromString(String id) { - return Registries.PARTICLE_TYPE.getOrEmpty(Identifier.of(id)); + return Registries.PARTICLE_TYPE.getOptionalValue(Identifier.of(id)); } public record Entry(EntityType entity, ParticleEffect particle) { diff --git a/src/main/java/visuality/registry/ShinyArmorRegistry.java b/src/main/java/visuality/registry/ShinyArmorRegistry.java index 29ef166..eea49bc 100644 --- a/src/main/java/visuality/registry/ShinyArmorRegistry.java +++ b/src/main/java/visuality/registry/ShinyArmorRegistry.java @@ -42,6 +42,6 @@ public static boolean isShiny(ItemStack item) { } private static Optional getItemFromString(String id) { - return Registries.ITEM.getOrEmpty(Identifier.of(id)); + return Registries.ITEM.getOptionalValue(Identifier.of(id)); } } diff --git a/src/main/java/visuality/registry/ShinyBlockRegistry.java b/src/main/java/visuality/registry/ShinyBlockRegistry.java index 9d7fbc4..bed3e4d 100644 --- a/src/main/java/visuality/registry/ShinyBlockRegistry.java +++ b/src/main/java/visuality/registry/ShinyBlockRegistry.java @@ -43,6 +43,6 @@ public static boolean isShiny(BlockState block) { } private static Optional getBlockFromString(String id) { - return Registries.BLOCK.getOrEmpty(Identifier.of(id)); + return Registries.BLOCK.getOptionalValue(Identifier.of(id)); } }