Skip to content

Commit c4a533e

Browse files
IxPrumxIDrexHD
andauthored
1.21.10 and 1.21.9 Update (#338)
Co-authored-by: Drex <[email protected]>
1 parent aead290 commit c4a533e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+448
-135
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ kotlin.code.style=official
22
org.gradle.jvmargs=-Xmx2G
33

44
# Mod Properties
5-
modVersion = 1.3.13
5+
modVersion = 1.3.14
66
mavenGroup = com.github.quiltservertools
77
modId = ledger
88
modName = Ledger

libs.versions.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
[versions]
2-
minecraft = "1.21.8"
3-
yarn-mappings = "1.21.8+build.1"
4-
fabric-loader = "0.17.1"
2+
minecraft = "1.21.10-rc1"
3+
yarn-mappings = "1.21.10-rc1+build.1"
4+
fabric-loader = "0.17.2"
55

6-
fabric-api = "0.131.0+1.21.8"
6+
fabric-api = "0.134.1+1.21.10"
77

88
# Kotlin
99
kotlin = "2.2.0"
1010
# Also modrinth version in gradle.properties
1111
fabric-kotlin = "1.13.4+kotlin.2.2.0"
1212

1313
fabric-permissions = "0.4.1"
14-
translations = "2.5.1+1.21.5"
14+
translations = "2.5.2+1.21.9-pre3"
1515

1616
exposed = "0.61.0"
1717
sqlite-jdbc = "3.50.3.0"

src/main/java/com/github/quiltservertools/ledger/mixin/BucketDispenserBehaviorMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public abstract class BucketDispenserBehaviorMixin extends ItemDispenserBehavior
2929
private void logFluidPickup(BlockPointer pointer, ItemStack stack, CallbackInfoReturnable<ItemStack> cir, @Local(argsOnly = true) ItemStack itemStack, @Local BlockPos pos, @Local BlockState blockState) {
3030
var world = pointer.world();
3131
if (!itemStack.isEmpty()) {
32-
if (blockState.isLiquid() || blockState.isOf(Blocks.POWDER_SNOW)) {
32+
if (!blockState.getFluidState().isEmpty() || blockState.isOf(Blocks.POWDER_SNOW)) {
3333
BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, blockState, world.getBlockEntity(pos), Sources.REDSTONE);
3434
} else {
3535
BlockChangeCallback.EVENT.invoker().changeBlock(
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.github.quiltservertools.ledger.mixin;
2+
3+
import com.github.quiltservertools.ledger.callbacks.ItemDropCallback;
4+
import com.llamalad7.mixinextras.sugar.Local;
5+
import net.minecraft.entity.ItemEntity;
6+
import net.minecraft.entity.LivingEntity;
7+
import net.minecraft.entity.ai.brain.task.TargetUtil;
8+
import net.minecraft.entity.passive.CopperGolemEntity;
9+
import net.minecraft.item.ItemStack;
10+
import net.minecraft.util.math.Vec3d;
11+
import org.spongepowered.asm.mixin.Mixin;
12+
import org.spongepowered.asm.mixin.injection.At;
13+
import org.spongepowered.asm.mixin.injection.Inject;
14+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
15+
16+
@Mixin(TargetUtil.class)
17+
public class CopperGolemGiveMixin {
18+
19+
@Inject(method = "give(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Vec3d;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z"))
20+
private static void onItemGiven(LivingEntity entity, ItemStack stack, Vec3d targetLocation, Vec3d velocityFactor, float yOffset, CallbackInfo ci, @Local ItemEntity itemEntity) {
21+
if (entity instanceof CopperGolemEntity) {
22+
ItemDropCallback.EVENT.invoker().drop(itemEntity, entity);
23+
}
24+
}
25+
}

src/main/java/com/github/quiltservertools/ledger/mixin/DyeItemMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ private void ledgerOldEntity(ItemStack stack, PlayerEntity player, LivingEntity
2828

2929
@Inject(method = "useOnEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/SheepEntity;setColor(Lnet/minecraft/util/DyeColor;)V", shift = At.Shift.AFTER))
3030
private void ledgerPlayerDyeSheep(ItemStack stack, PlayerEntity player, LivingEntity entity, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
31-
EntityModifyCallback.EVENT.invoker().modify(player.getWorld(), entity.getBlockPos(), oldEntityTags, entity, stack, player, Sources.DYE);
31+
EntityModifyCallback.EVENT.invoker().modify(player.getEntityWorld(), entity.getBlockPos(), oldEntityTags, entity, stack, player, Sources.DYE);
3232
}
3333
}

src/main/java/com/github/quiltservertools/ledger/mixin/HoneycombItemMixin.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.github.quiltservertools.ledger.callbacks.BlockChangeCallback;
44
import com.github.quiltservertools.ledger.utility.Sources;
5+
import com.llamalad7.mixinextras.sugar.Local;
56
import net.minecraft.block.BlockState;
67
import net.minecraft.entity.player.PlayerEntity;
78
import net.minecraft.item.HoneycombItem;
@@ -16,10 +17,10 @@
1617
@Mixin(HoneycombItem.class)
1718
public abstract class HoneycombItemMixin {
1819
@ModifyArgs(method = "method_34719", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
19-
private static void logCopperWaxing(Args args, ItemUsageContext context, BlockPos pos, World world, BlockState state) {
20+
private static void logCopperWaxing(Args args, @Local World world, @Local PlayerEntity player) {
21+
BlockPos pos = args.get(0);
2022
BlockState oldState = world.getBlockState(pos);
2123
BlockState newState = args.get(1);
22-
PlayerEntity player = context.getPlayer();
2324
if (player == null) {
2425
BlockChangeCallback.EVENT.invoker().changeBlock(world, pos, oldState, newState, null, null, Sources.INTERACT);
2526
} else {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.github.quiltservertools.ledger.mixin;
2+
3+
import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback;
4+
import com.github.quiltservertools.ledger.utility.Sources;
5+
import com.llamalad7.mixinextras.sugar.Local;
6+
import net.minecraft.block.BlockState;
7+
import net.minecraft.block.Blocks;
8+
import net.minecraft.entity.Entity;
9+
import net.minecraft.entity.player.PlayerEntity;
10+
import net.minecraft.util.math.BlockPos;
11+
import net.minecraft.world.World;
12+
import org.spongepowered.asm.mixin.Mixin;
13+
import org.spongepowered.asm.mixin.injection.At;
14+
import org.spongepowered.asm.mixin.injection.Inject;
15+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
16+
17+
@Mixin(World.class)
18+
public abstract class LilyPadBreakageMixin {
19+
@Inject(method = "breakBlock", at = @At(value = "RETURN", ordinal = 1))
20+
private void ledgerModifyLilyPadBreakArgs(BlockPos pos, boolean drop, Entity entity, int maxUpdateDepth, CallbackInfoReturnable<Boolean> cir, @Local BlockState state) {
21+
if (!state.getBlock().equals(Blocks.LILY_PAD)) return;
22+
World world = (World) (Object) this;
23+
if (entity.getFirstPassenger() instanceof PlayerEntity player) {
24+
BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, state, null, Sources.VEHICLE, player);
25+
} else {
26+
BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, state, null, Sources.VEHICLE);
27+
}
28+
}
29+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.github.quiltservertools.ledger.mixin;
2+
3+
import com.github.quiltservertools.ledger.callbacks.ItemInsertCallback;
4+
import com.github.quiltservertools.ledger.callbacks.ItemRemoveCallback;
5+
import com.github.quiltservertools.ledger.utility.Sources;
6+
import net.minecraft.entity.EquipmentSlot;
7+
import net.minecraft.entity.ai.brain.task.MoveItemsTask;
8+
import net.minecraft.entity.mob.PathAwareEntity;
9+
import net.minecraft.inventory.Inventory;
10+
import net.minecraft.item.ItemStack;
11+
import net.minecraft.server.world.ServerWorld;
12+
import net.minecraft.util.math.BlockPos;
13+
import net.minecraft.world.World;
14+
import org.spongepowered.asm.mixin.Mixin;
15+
import org.spongepowered.asm.mixin.Shadow;
16+
import org.spongepowered.asm.mixin.Unique;
17+
import org.spongepowered.asm.mixin.injection.At;
18+
import org.spongepowered.asm.mixin.injection.Inject;
19+
import org.spongepowered.asm.mixin.injection.ModifyArgs;
20+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
21+
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
22+
import java.util.WeakHashMap;
23+
24+
@Mixin(MoveItemsTask.class)
25+
public class MoveItemsTaskMixin {
26+
27+
@Shadow
28+
private MoveItemsTask.Storage targetStorage;
29+
30+
@Unique
31+
private static final WeakHashMap<PathAwareEntity, BlockPos> ledger$entityTargetMap = new WeakHashMap<>();
32+
33+
@Inject(method = "takeStack", at = @At(value = "INVOKE", target = "Lnet/minecraft/inventory/Inventory;markDirty()V"))
34+
public void onTakeStack(PathAwareEntity entity, Inventory inventory, CallbackInfo ci) {
35+
ItemStack stack = entity.getEquippedStack(EquipmentSlot.MAINHAND);
36+
World world = entity.getEntityWorld();
37+
ItemRemoveCallback.EVENT.invoker().remove(stack, targetStorage.pos(), (ServerWorld) world, Sources.COPPER_GOLEM, entity);
38+
}
39+
40+
@Inject(method = "placeStack", at = @At(value = "INVOKE", target = "Lnet/minecraft/inventory/Inventory;markDirty()V"))
41+
private void onPlaceStack(PathAwareEntity entity, Inventory inventory, CallbackInfo ci) {
42+
ledger$entityTargetMap.put(entity, targetStorage.pos());
43+
}
44+
45+
@Inject(method = "invalidateTargetStorage", at = @At("HEAD"))
46+
private void onInvalidateTargetStorage(PathAwareEntity entity, CallbackInfo ci) {
47+
ledger$entityTargetMap.remove(entity);
48+
}
49+
50+
@ModifyArgs(method = "insertStack", at = @At(value = "INVOKE", target = "Lnet/minecraft/inventory/Inventory;setStack(ILnet/minecraft/item/ItemStack;)V"))
51+
private static void onInsertStack(Args args, PathAwareEntity entity, Inventory inventory) {
52+
ItemStack itemStack = args.get(1);
53+
World world = entity.getEntityWorld();
54+
BlockPos targetPos = ledger$entityTargetMap.getOrDefault(entity, null);
55+
if (targetPos == null) return;
56+
57+
ItemInsertCallback.EVENT.invoker().insert(itemStack, targetPos, (ServerWorld) world, Sources.COPPER_GOLEM, entity);
58+
}
59+
}

src/main/java/com/github/quiltservertools/ledger/mixin/ScreenHandlerMixin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private void ledgerDropInventoryGetPlayer(PlayerEntity player, Inventory invento
6666

6767
@Inject(method = "onClosed", at = @At(value = "RETURN"))
6868
private void ledgerCloseScreenLogChanges(PlayerEntity player, CallbackInfo ci) {
69-
if (!player.getWorld().isClient && pos != null) {
69+
if (!player.getEntityWorld().isClient() && pos != null) {
7070
for (var pair : changedStacks.keySet()) {
7171
ItemStack stack = new ItemStack(Registries.ITEM.getEntry(pair.getItem()), 1, pair.getChanges());
7272
if (stack.isEmpty()) {
@@ -82,11 +82,11 @@ private void ledgerCloseScreenLogChanges(PlayerEntity player, CallbackInfo ci) {
8282
}
8383
if (count > 0) {
8484
for (ItemStack splitStack : splitStacks) {
85-
ItemInsertCallback.EVENT.invoker().insert(splitStack, pos, (ServerWorld) player.getWorld(), Sources.PLAYER, (ServerPlayerEntity) player);
85+
ItemInsertCallback.EVENT.invoker().insert(splitStack, pos, (ServerWorld) player.getEntityWorld(), Sources.PLAYER, (ServerPlayerEntity) player);
8686
}
8787
} else {
8888
for (ItemStack splitStack : splitStacks) {
89-
ItemRemoveCallback.EVENT.invoker().remove(splitStack, pos, (ServerWorld) player.getWorld(), Sources.PLAYER, (ServerPlayerEntity) player);
89+
ItemRemoveCallback.EVENT.invoker().remove(splitStack, pos, (ServerWorld) player.getEntityWorld(), Sources.PLAYER, (ServerPlayerEntity) player);
9090
}
9191
}
9292
}

src/main/java/com/github/quiltservertools/ledger/mixin/ServerPlayerEntityMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void addPositionContext(NamedScreenHandlerFactory factory, CallbackInfoRe
3131
}
3232

3333
@Inject(method = "startRiding", at = @At(value = "RETURN"))
34-
public void onPlayerStartedRiding(Entity entity, boolean force, CallbackInfoReturnable<Boolean> cir) {
34+
public void onPlayerStartedRiding(Entity entity, boolean force, boolean emitEvent, CallbackInfoReturnable<Boolean> cir) {
3535
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
3636

3737
if (!cir.getReturnValue()) {

0 commit comments

Comments
 (0)