From e4b524e162c81103f41e756abe4e6968b6112f47 Mon Sep 17 00:00:00 2001 From: Majrusz Date: Sat, 2 Mar 2024 10:49:40 +0100 Subject: [PATCH 1/7] Updated version name --- changelog.md | 5 ----- gradle.properties | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/changelog.md b/changelog.md index e6b9b8fa..e69de29b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +0,0 @@ -- fixed random crashes when starting the game (reported by @Kazuya) -- fixed bug with spawn point features not working properly with Respawn Anchors -- fixed bug with item damage modifications not working properly (reported by @Camawama) -- fixed compatibility issue that caused 1 item to be taken from the stack when hitting mobs (reported by @Camawama) -- optimized spawn point features \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 28bddf21..b4b5b2f6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ minecraft_version=1.20.1 # Mod mod_id=majruszlibrary mod_archives_name=majrusz-library -mod_version=7.0.5 +mod_version=7.0.6-unfinished mod_display_name=Majrusz Library mod_description=Library with common code for my other modifications. mod_authors=Majrusz From e51f134d6d249c6bf3f6a27c3534c5b6503bb7ff Mon Sep 17 00:00:00 2001 From: Majrusz Date: Sat, 2 Mar 2024 10:50:06 +0100 Subject: [PATCH 2/7] Fixed crash `Accessing LegacyRandomSource from multiple threads` (reported by @Luigi delle Bicocche, @davey) --- changelog.md | 1 + common/src/main/java/com/majruszlibrary/math/Random.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index e69de29b..820b4de7 100644 --- a/changelog.md +++ b/changelog.md @@ -0,0 +1 @@ +- fixed crash `Accessing LegacyRandomSource from multiple threads` (reported by @Luigi delle Bicocche, @davey) \ No newline at end of file diff --git a/common/src/main/java/com/majruszlibrary/math/Random.java b/common/src/main/java/com/majruszlibrary/math/Random.java index 16314170..e68f7f66 100644 --- a/common/src/main/java/com/majruszlibrary/math/Random.java +++ b/common/src/main/java/com/majruszlibrary/math/Random.java @@ -19,7 +19,7 @@ public class Random { thread safe and can be accessed on both server and client at the same time. */ public static RandomSource getThreadSafe() { - return Side.isLogicalClient() ? CLIENT : SERVER; + return Side.isClient() ? CLIENT : SERVER; } public static float nextFloat() { From 1aa25543d403164a2c882dd2a3ea100c4fb7b333 Mon Sep 17 00:00:00 2001 From: Majrusz Date: Sun, 17 Mar 2024 08:39:01 +0100 Subject: [PATCH 3/7] Fixed compatibility crash `java.lang.IndexOutOfBoundsException` (reported by @GermanArtur, @memphismc) --- changelog.md | 3 ++- common/src/main/java/com/majruszlibrary/time/TimeHelper.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 820b4de7..283dbf5f 100644 --- a/changelog.md +++ b/changelog.md @@ -1 +1,2 @@ -- fixed crash `Accessing LegacyRandomSource from multiple threads` (reported by @Luigi delle Bicocche, @davey) \ No newline at end of file +- fixed crash `Accessing LegacyRandomSource from multiple threads` (reported by @Luigi delle Bicocche, @davey) +- fixed compatibility crash `java.lang.IndexOutOfBoundsException` (reported by @GermanArtur, @memphismc) \ No newline at end of file diff --git a/common/src/main/java/com/majruszlibrary/time/TimeHelper.java b/common/src/main/java/com/majruszlibrary/time/TimeHelper.java index e469f121..6ff566e5 100644 --- a/common/src/main/java/com/majruszlibrary/time/TimeHelper.java +++ b/common/src/main/java/com/majruszlibrary/time/TimeHelper.java @@ -25,7 +25,7 @@ public class TimeHelper { private static final int TICKS_IN_MINUTE = TICKS_IN_SECOND * 60; private static final LogicalSafe< List< IDelayedExecution > > PENDING_EXECUTIONS = LogicalSafe.of( ArrayList::new ); private static final LogicalSafe< List< IDelayedExecution > > EXECUTIONS = LogicalSafe.of( ArrayList::new ); - private static LogicalSafe< Long > TICKS_COUNTER = LogicalSafe.of( ()->-1L ); + private static LogicalSafe< Long > TICKS_COUNTER = LogicalSafe.of( ()->1L ); static { OnServerTicked.listen( data->TimeHelper.update() ) From 5fbdce123e93d2acf2269ebc13f6e247313d3a73 Mon Sep 17 00:00:00 2001 From: Majrusz Date: Sun, 14 Apr 2024 12:30:25 +0200 Subject: [PATCH 4/7] Added compatibility for fishing related features with Aquaculture 2 (reported by @JinKhya, @Ladocterus) --- changelog.md | 1 + .../events/OnItemFishedForge.java | 17 +++++++++ .../mixin/forge/MixinFishingHook.java | 35 ------------------- .../majruszlibrary-forge.mixins.json | 1 - 4 files changed, 18 insertions(+), 36 deletions(-) create mode 100644 forge/src/main/java/com/majruszlibrary/events/OnItemFishedForge.java delete mode 100644 forge/src/main/java/com/majruszlibrary/mixin/forge/MixinFishingHook.java diff --git a/changelog.md b/changelog.md index 283dbf5f..853e8d14 100644 --- a/changelog.md +++ b/changelog.md @@ -1,2 +1,3 @@ +- added compatibility with Aquaculture 2 for fishing related features (reported by @JinKhya, @Ladocterus) - fixed crash `Accessing LegacyRandomSource from multiple threads` (reported by @Luigi delle Bicocche, @davey) - fixed compatibility crash `java.lang.IndexOutOfBoundsException` (reported by @GermanArtur, @memphismc) \ No newline at end of file diff --git a/forge/src/main/java/com/majruszlibrary/events/OnItemFishedForge.java b/forge/src/main/java/com/majruszlibrary/events/OnItemFishedForge.java new file mode 100644 index 00000000..d1f432fd --- /dev/null +++ b/forge/src/main/java/com/majruszlibrary/events/OnItemFishedForge.java @@ -0,0 +1,17 @@ +package com.majruszlibrary.events; + +import com.majruszlibrary.events.base.Events; +import net.minecraft.world.entity.player.Player; +import net.minecraftforge.event.entity.player.ItemFishedEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; + +@Mod.EventBusSubscriber +public class OnItemFishedForge { + @SubscribeEvent + public static void onItemFished( ItemFishedEvent event ) { + Player player = event.getEntity(); + + Events.dispatch( new OnItemFished( player, event.getHookEntity(), player.getItemInHand( player.getUsedItemHand() ), event.getDrops() ) ); + } +} diff --git a/forge/src/main/java/com/majruszlibrary/mixin/forge/MixinFishingHook.java b/forge/src/main/java/com/majruszlibrary/mixin/forge/MixinFishingHook.java deleted file mode 100644 index df88ab8a..00000000 --- a/forge/src/main/java/com/majruszlibrary/mixin/forge/MixinFishingHook.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.majruszlibrary.mixin.forge; - -import com.majruszlibrary.events.OnItemFished; -import com.majruszlibrary.events.base.Events; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.entity.projectile.FishingHook; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.storage.loot.LootParams; -import net.minecraft.world.level.storage.loot.LootTable; -import net.minecraftforge.event.entity.player.ItemFishedEvent; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import java.util.List; - -@Mixin( FishingHook.class ) -public abstract class MixinFishingHook { - @Inject( - at = @At( - ordinal = 1, - target = "Lnet/minecraft/advancements/critereon/FishingRodHookedTrigger;trigger (Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/projectile/FishingHook;Ljava/util/Collection;)V", - value = "INVOKE" - ), - locals = LocalCapture.CAPTURE_FAILHARD, - method = "retrieve (Lnet/minecraft/world/item/ItemStack;)I" - ) - private void retrieve( ItemStack itemStack, CallbackInfoReturnable< Integer > callback, Player player, int damage, ItemFishedEvent event, - LootParams lootParams, LootTable lootTable, List< ItemStack > items - ) { - Events.dispatch( new OnItemFished( player, ( FishingHook )( Object )this, itemStack, items ) ); - } -} diff --git a/forge/src/main/resources/majruszlibrary-forge.mixins.json b/forge/src/main/resources/majruszlibrary-forge.mixins.json index c65aeeed..bb89032f 100644 --- a/forge/src/main/resources/majruszlibrary-forge.mixins.json +++ b/forge/src/main/resources/majruszlibrary-forge.mixins.json @@ -9,7 +9,6 @@ ], "mixins": [ "MixinEnchantment", - "MixinFishingHook", "MixinLootTable" ], "injectors": { From e14b10e8b9ac33f0d03bbcb183032a1f21278159 Mon Sep 17 00:00:00 2001 From: Majrusz Date: Thu, 25 Apr 2024 16:44:20 +0200 Subject: [PATCH 5/7] Added compatibility with MC Dungeons Weapons for damage related features (reported by @mochalit) --- changelog.md | 1 + .../main/java/com/majruszlibrary/mixin/MixinLivingEntity.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 853e8d14..f049c1f8 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,4 @@ - added compatibility with Aquaculture 2 for fishing related features (reported by @JinKhya, @Ladocterus) +- added compatibility with MC Dungeons Weapons for damage related features (reported by @mochalit) - fixed crash `Accessing LegacyRandomSource from multiple threads` (reported by @Luigi delle Bicocche, @davey) - fixed compatibility crash `java.lang.IndexOutOfBoundsException` (reported by @GermanArtur, @memphismc) \ No newline at end of file diff --git a/common/src/main/java/com/majruszlibrary/mixin/MixinLivingEntity.java b/common/src/main/java/com/majruszlibrary/mixin/MixinLivingEntity.java index 418608b5..e0d7e743 100644 --- a/common/src/main/java/com/majruszlibrary/mixin/MixinLivingEntity.java +++ b/common/src/main/java/com/majruszlibrary/mixin/MixinLivingEntity.java @@ -26,7 +26,7 @@ import java.util.Map; -@Mixin( LivingEntity.class ) +@Mixin( value = LivingEntity.class, priority = 1100 ) public abstract class MixinLivingEntity implements IMixinLivingEntity { private @Shadow int useItemRemaining; float majruszlibrary$lastDamage = 0.0f; From b1110055f095502c7de35e4f4c63a32b1405edfd Mon Sep 17 00:00:00 2001 From: Majrusz Date: Fri, 26 Apr 2024 16:34:47 +0200 Subject: [PATCH 6/7] Fixed long game loading time when GitHub cannot be accessed without proxy (reported by @SettingDust) --- changelog.md | 3 ++- .../java/com/majruszlibrary/modhelper/VersionChecker.java | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index f049c1f8..a5298b6d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,5 @@ - added compatibility with Aquaculture 2 for fishing related features (reported by @JinKhya, @Ladocterus) - added compatibility with MC Dungeons Weapons for damage related features (reported by @mochalit) - fixed crash `Accessing LegacyRandomSource from multiple threads` (reported by @Luigi delle Bicocche, @davey) -- fixed compatibility crash `java.lang.IndexOutOfBoundsException` (reported by @GermanArtur, @memphismc) \ No newline at end of file +- fixed compatibility crash `java.lang.IndexOutOfBoundsException` (reported by @GermanArtur, @memphismc) +- fixed long game loading time when GitHub cannot be accessed without proxy (reported by @SettingDust) \ No newline at end of file diff --git a/common/src/main/java/com/majruszlibrary/modhelper/VersionChecker.java b/common/src/main/java/com/majruszlibrary/modhelper/VersionChecker.java index da1ae304..4b33382e 100644 --- a/common/src/main/java/com/majruszlibrary/modhelper/VersionChecker.java +++ b/common/src/main/java/com/majruszlibrary/modhelper/VersionChecker.java @@ -54,6 +54,11 @@ public VersionChecker( ModHelper helper ) { } public void register() { + Thread thread = new Thread( VersionChecker.this::findAvailableUpdates ); + thread.start(); + } + + private void findAvailableUpdates() { Optional< URL > update = Integration.getUpdateURL( this.helper.getModId() ); if( update.isEmpty() ) { this.helper.logError( "Missing update url" ); From 377e4ede862f5aa892f0e554d28e34952abb47c7 Mon Sep 17 00:00:00 2001 From: Majrusz Date: Fri, 26 Apr 2024 16:35:25 +0200 Subject: [PATCH 7/7] Removed unfinished tag --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index b4b5b2f6..7fcb4612 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ minecraft_version=1.20.1 # Mod mod_id=majruszlibrary mod_archives_name=majrusz-library -mod_version=7.0.6-unfinished +mod_version=7.0.6 mod_display_name=Majrusz Library mod_description=Library with common code for my other modifications. mod_authors=Majrusz