diff --git a/changelog.md b/changelog.md index 7d24af53..1de73e12 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1 @@ -- fixed game crash `java.lang.NullPointerException: Registry Object not present` (reported by @reboundrefice) -- fixed bug with trying to load folders instead of mods (reported by @SettingDust) -- fixed bug with weather changes not working properly -- fixed compatibility issue with Sodium (reported by @LonelyFear) -- fixed compatibility issue with Epic Fight (reported by @Orphion_) -- fixed compatibility issue with Marium's Soulslike Weaponry (reported by @mariumbacchus) \ No newline at end of file +- fixed compatibility bug with items not dropping at all when Porting Lib is used (reported by @Cornell) \ No newline at end of file diff --git a/common/src/main/java/com/majruszlibrary/math/AnyPos.java b/common/src/main/java/com/majruszlibrary/math/AnyPos.java index 192a5ff2..321ae069 100644 --- a/common/src/main/java/com/majruszlibrary/math/AnyPos.java +++ b/common/src/main/java/com/majruszlibrary/math/AnyPos.java @@ -364,6 +364,6 @@ public Vec3i vec3i() { } public BlockPos block() { - return new BlockPos( ( int )this.x, ( int )this.y, ( int )this.z ); + return new BlockPos( ( int )Math.floor( this.x ), ( int )Math.floor( this.y ), ( int )Math.floor( this.z ) ); } } diff --git a/fabric/src/main/java/com/majruszlibrary/mixin/fabric/MixinLootTable.java b/fabric/src/main/java/com/majruszlibrary/mixin/fabric/MixinLootTable.java index b4769bd6..c1ea7d9c 100644 --- a/fabric/src/main/java/com/majruszlibrary/mixin/fabric/MixinLootTable.java +++ b/fabric/src/main/java/com/majruszlibrary/mixin/fabric/MixinLootTable.java @@ -10,13 +10,11 @@ import net.minecraft.world.level.storage.loot.LootTable; 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.ModifyVariable; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.function.Consumer; -@Mixin( LootTable.class ) +@Mixin( value = LootTable.class, priority = 990 ) public abstract class MixinLootTable implements IMixinLootTable { ResourceLocation majruszlibrary$id = null; Consumer< ItemStack > majruszlibrary$consumer = itemStack->{}; @@ -27,11 +25,8 @@ public abstract class MixinLootTable implements IMixinLootTable { this.majruszlibrary$id = id; } - @Inject( - at = @At( "RETURN" ), - method = "getRandomItemsRaw (Lnet/minecraft/world/level/storage/loot/LootContext;Ljava/util/function/Consumer;)V" - ) - private void getRandomItemsRaw( LootContext context, Consumer< ItemStack > consumer, CallbackInfo callback ) { + @Override + public void majruszlibrary$modify( LootContext context ) { Events.dispatch( new OnLootGenerated( this.majruszlibrary$items, this.majruszlibrary$id, context ) ).generatedLoot.forEach( this.majruszlibrary$consumer ); } diff --git a/fabric/src/main/java/com/majruszlibrary/mixin/fabric/MixinLootTable2.java b/fabric/src/main/java/com/majruszlibrary/mixin/fabric/MixinLootTable2.java new file mode 100644 index 00000000..c9e410ba --- /dev/null +++ b/fabric/src/main/java/com/majruszlibrary/mixin/fabric/MixinLootTable2.java @@ -0,0 +1,23 @@ +package com.majruszlibrary.mixin.fabric; + +import com.majruszlibrary.mixininterfaces.fabric.IMixinLootTable; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootTable; +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 java.util.function.Consumer; + +@Mixin( value = LootTable.class, priority = 1010 ) +public abstract class MixinLootTable2 implements IMixinLootTable { + @Inject( + at = @At( "RETURN" ), + method = "getRandomItemsRaw (Lnet/minecraft/world/level/storage/loot/LootContext;Ljava/util/function/Consumer;)V" + ) + private void getRandomItemsRaw( LootContext context, Consumer< ItemStack > consumer, CallbackInfo callback ) { + this.majruszlibrary$modify( context ); // compatibility with porting library + } +} diff --git a/fabric/src/main/java/com/majruszlibrary/mixininterfaces/fabric/IMixinLootTable.java b/fabric/src/main/java/com/majruszlibrary/mixininterfaces/fabric/IMixinLootTable.java index 4227880f..4d1f7cc0 100644 --- a/fabric/src/main/java/com/majruszlibrary/mixininterfaces/fabric/IMixinLootTable.java +++ b/fabric/src/main/java/com/majruszlibrary/mixininterfaces/fabric/IMixinLootTable.java @@ -1,7 +1,10 @@ package com.majruszlibrary.mixininterfaces.fabric; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.storage.loot.LootContext; public interface IMixinLootTable { void majruszlibrary$set( ResourceLocation id ); + + void majruszlibrary$modify( LootContext context ); } diff --git a/fabric/src/main/resources/majruszlibrary-fabric.mixins.json b/fabric/src/main/resources/majruszlibrary-fabric.mixins.json index 156967c6..3dc04893 100644 --- a/fabric/src/main/resources/majruszlibrary-fabric.mixins.json +++ b/fabric/src/main/resources/majruszlibrary-fabric.mixins.json @@ -17,6 +17,7 @@ "MixinLivingEntity", "MixinLootDataType", "MixinLootTable", + "MixinLootTable2", "MixinLootTableBuilder", "MixinPlayer" ], diff --git a/gradle.properties b/gradle.properties index ae9a6a4a..3bf48a0e 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.1 +mod_version=7.0.2 mod_display_name=Majrusz Library mod_description=Library with common code for my other modifications. mod_authors=Majrusz