Skip to content

Commit

Permalink
Merged 7.0.7 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Majrusz committed Apr 27, 2024
2 parents 6332d19 + 2cb7264 commit cdf517a
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 44 deletions.
8 changes: 3 additions & 5 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
- 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)
- fixed long game loading time when GitHub cannot be accessed without proxy (reported by @SettingDust)
- added missing compatibility for Aquaculture 2 (reported by @LilChromie)
- added Aquaculture 2 compatibility for NeoForge (reported by @LilChromie)
- fixed random server crash `Accessing LegacyRandomSource from multiple threads` (reported by @AVeryLittleGhost, @memphismc)
9 changes: 8 additions & 1 deletion common/src/main/java/com/majruszlibrary/math/Random.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.stream.IntStream;

public class Random {
static final RandomSource LOGICAL_CLIENT = RandomSource.create();
static final RandomSource CLIENT = RandomSource.create();
static final RandomSource SERVER = RandomSource.create();

Expand All @@ -19,7 +20,13 @@ public class Random {
thread safe and can be accessed on both server and client at the same time.
*/
public static RandomSource getThreadSafe() {
return Side.isClient() ? CLIENT : SERVER;
if( Side.isLogicalClient() ) {
return LOGICAL_CLIENT;
} else if( Side.isClient() ) {
return CLIENT;
} else {
return SERVER;
}
}

public static float nextFloat() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@Mixin( FishingHook.class )
public abstract class MixinFishingHook {
private @Shadow int timeUntilLured;
protected @Shadow int timeUntilLured;

@Redirect(
at = @At(
Expand Down
1 change: 1 addition & 0 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ java {
dependencies {
minecraft "net.minecraftforge:forge:${forge_version}"
compileOnly project(':common')
implementation fg.deobf('curse.maven:aquaculture-60028:4608454')
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.majruszlibrary.mixin.forge;

import com.majruszlibrary.events.OnFishingTimeGet;
import com.majruszlibrary.events.base.Events;
import com.majruszlibrary.mixin.MixinFishingHook;
import com.teammetallurgy.aquaculture.entity.AquaFishingBobberEntity;
import org.spongepowered.asm.mixin.Dynamic;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Pseudo
@Mixin( targets = "com.teammetallurgy.aquaculture.entity.AquaFishingBobberEntity" )
public abstract class MixinAquaFishingBobberEntity extends MixinFishingHook {
@Dynamic( "Aquaculture 2 compatibility" )
@Redirect(
at = @At(
opcode = 181, // putfield
ordinal = 3,
target = "Lcom/teammetallurgy/aquaculture/entity/AquaFishingBobberEntity;timeUntilLured:I",
value = "FIELD"
),
method = "catchingFish (Lnet/minecraft/core/BlockPos;)V"
)
private void catchingFish( AquaFishingBobberEntity hook, int timeUntilLured ) {
this.timeUntilLured = Events.dispatch( new OnFishingTimeGet( hook, timeUntilLured ) ).getTicks();
}
}
1 change: 1 addition & 0 deletions forge/src/main/resources/majruszlibrary-forge.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"MixinAbstractContainerScreen"
],
"mixins": [
"MixinAquaFishingBobberEntity",
"MixinEnchantment",
"MixinLootTable"
],
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ minecraft_version=1.20.1
# Mod
mod_id=majruszlibrary
mod_archives_name=majrusz-library
mod_version=7.0.6
mod_version=7.0.7
mod_display_name=Majrusz Library
mod_description=Library with common code for my other modifications.
mod_authors=Majrusz
Expand Down
1 change: 1 addition & 0 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ java {
dependencies {
minecraft "net.neoforged:forge:${neoforge_version}"
compileOnly project(':common')
implementation fg.deobf('curse.maven:aquaculture-60028:4921323')
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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 OnItemFishedNeoForge {
@SubscribeEvent
public static void onItemFished( ItemFishedEvent event ) {
Player player = event.getEntity();

Events.dispatch( new OnItemFished( player, event.getHookEntity(), player.getItemInHand( player.getUsedItemHand() ), event.getDrops() ) );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.majruszlibrary.mixin.neoforge;

import com.majruszlibrary.events.OnFishingTimeGet;
import com.majruszlibrary.events.base.Events;
import com.majruszlibrary.mixin.MixinFishingHook;
import com.teammetallurgy.aquaculture.entity.AquaFishingBobberEntity;
import org.spongepowered.asm.mixin.Dynamic;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Pseudo
@Mixin( targets = "com.teammetallurgy.aquaculture.entity.AquaFishingBobberEntity" )
public abstract class MixinAquaFishingBobberEntity extends MixinFishingHook {
@Dynamic( "Aquaculture 2 compatibility" )
@Redirect(
at = @At(
opcode = 181, // putfield
ordinal = 3,
target = "Lcom/teammetallurgy/aquaculture/entity/AquaFishingBobberEntity;timeUntilLured:I",
value = "FIELD"
),
method = "catchingFish (Lnet/minecraft/core/BlockPos;)V"
)
private void catchingFish( AquaFishingBobberEntity hook, int timeUntilLured ) {
this.timeUntilLured = Events.dispatch( new OnFishingTimeGet( hook, timeUntilLured ) ).getTicks();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"MixinAbstractContainerScreen"
],
"mixins": [
"MixinAquaFishingBobberEntity",
"MixinEnchantment",
"MixinFishingHook",
"MixinLootTable"
],
"injectors": {
Expand Down

0 comments on commit cdf517a

Please sign in to comment.