Skip to content

Commit fe7ac87

Browse files
committed
Backport to 1.20.1
1 parent 258a731 commit fe7ac87

File tree

120 files changed

+1138
-1583
lines changed

Some content is hidden

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

120 files changed

+1138
-1583
lines changed

libs.versions.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[versions]
2-
minecraft = "1.21.11-rc2"
3-
fabric-loader = "0.18.1"
2+
minecraft = "1.20.1"
3+
fabric-loader = "0.18.4"
44

5-
fabric-api = "0.139.4+1.21.11"
5+
fabric-api = "0.92.6+1.20.1"
66

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

12-
fabric-permissions = "0.6.0-patbox"
13-
translations = "2.5.2+1.21.9-pre3"
12+
fabric-permissions = "0.2-SNAPSHOT"
13+
translations = "2.0.0+1.20"
1414

1515
exposed = "1.0.0-rc-2"
1616
sqlite-jdbc = "3.50.3.0"

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ private void ledgerDropInventoryGetPlayer(Player player, Container inventory, Ca
6868
private void ledgerCloseScreenLogChanges(Player player, CallbackInfo ci) {
6969
if (!player.level().isClientSide() && pos != null) {
7070
for (var pair : changedStacks.keySet()) {
71-
ItemStack stack = new ItemStack(BuiltInRegistries.ITEM.wrapAsHolder(pair.getItem()), 1, pair.getChanges());
71+
ItemStack stack = new ItemStack(BuiltInRegistries.ITEM.wrapAsHolder(pair.getItem()), 1);
72+
stack.setTag(pair.getChanges());
7273
if (stack.isEmpty()) {
7374
continue;
7475
}
@@ -114,15 +115,15 @@ public void setPos(@NotNull BlockPos pos) {
114115
public void onStackChanged(@NotNull ItemStack old, @NotNull ItemStack itemStack, @NotNull BlockPos pos) {
115116
if (old.isEmpty() && !itemStack.isEmpty()) {
116117
// Add item
117-
var key = new ItemData(itemStack.getItem(), itemStack.getComponentsPatch());
118+
var key = new ItemData(itemStack.getItem(), itemStack.getTag());
118119
if (changedStacks.containsKey(key)) {
119120
changedStacks.put(key, changedStacks.get(key) + itemStack.getCount());
120121
} else {
121122
changedStacks.put(key, itemStack.getCount());
122123
}
123124
} else if (!old.isEmpty() && itemStack.isEmpty()) {
124125
// Remove item
125-
var key = new ItemData(old.getItem(), old.getComponentsPatch());
126+
var key = new ItemData(old.getItem(), old.getTag());
126127
if (changedStacks.containsKey(key)) {
127128
changedStacks.put(key, changedStacks.get(key) - old.getCount());
128129
} else {

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

Lines changed: 0 additions & 55 deletions
This file was deleted.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public BlockItemMixin(Properties settings) {
2424
@Inject(
2525
method = "place(Lnet/minecraft/world/item/context/BlockPlaceContext;)Lnet/minecraft/world/InteractionResult;",
2626
at = @At(
27-
value = "FIELD",
28-
target = "Lnet/minecraft/world/InteractionResult;SUCCESS:Lnet/minecraft/world/InteractionResult$Success;"
27+
value = "INVOKE",
28+
target = "Lnet/minecraft/world/InteractionResult;sidedSuccess(Z)Lnet/minecraft/world/InteractionResult;"
2929
)
3030
)
3131
public void ledgerPlayerPlaceBlockCallback(BlockPlaceContext context, CallbackInfoReturnable<InteractionResult> cir) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@
44
import com.github.quiltservertools.ledger.callbacks.BlockChangeCallback;
55
import com.github.quiltservertools.ledger.utility.Sources;
66
import com.llamalad7.mixinextras.sugar.Local;
7+
import net.minecraft.core.BlockSource;
78
import net.minecraft.world.level.block.state.BlockState;
89
import net.minecraft.world.level.block.Blocks;
910
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
1011
import net.minecraft.world.item.ItemStack;
11-
import net.minecraft.core.dispenser.BlockSource;
1212
import net.minecraft.core.BlockPos;
1313
import org.spongepowered.asm.mixin.Mixin;
1414
import org.spongepowered.asm.mixin.injection.At;
1515
import org.spongepowered.asm.mixin.injection.Inject;
1616
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1717

18-
@Mixin(targets = "net.minecraft.core.dispenser.DispenseItemBehavior$5")
18+
@Mixin(targets = "net.minecraft.core.dispenser.DispenseItemBehavior$17")
1919
public abstract class BucketDispenserBehaviorMixin extends DefaultDispenseItemBehavior {
2020

2121
@Inject(
2222
method = "execute",
2323
at = @At(
2424
value = "INVOKE",
25-
target = "Lnet/minecraft/world/level/block/BucketPickup;pickupBlock(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack;",
25+
target = "Lnet/minecraft/world/level/block/BucketPickup;pickupBlock(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack;",
2626
shift = At.Shift.AFTER
2727
)
2828
)
2929
private void logFluidPickup(BlockSource pointer, ItemStack stack, CallbackInfoReturnable<ItemStack> cir, @Local(argsOnly = true) ItemStack itemStack, @Local BlockPos pos, @Local BlockState blockState) {
30-
var world = pointer.level();
30+
var world = pointer.getLevel();
3131
if (!itemStack.isEmpty()) {
3232
if (!blockState.getFluidState().isEmpty() || blockState.is(Blocks.POWDER_SNOW)) {
3333
BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, blockState, world.getBlockEntity(pos), Sources.REDSTONE);

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

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,52 +30,36 @@ public abstract class BucketItemMixin {
3030
private Fluid content;
3131

3232
@Inject(method = "emptyContents", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;destroyBlock(Lnet/minecraft/core/BlockPos;Z)Z"))
33-
private void logFluidBreak(LivingEntity user, Level world, BlockPos pos, BlockHitResult hitResult, CallbackInfoReturnable<Boolean> cir) {
33+
private void logFluidBreak(Player player, Level world, BlockPos pos, BlockHitResult blockHitResult, CallbackInfoReturnable<Boolean> cir) {
3434
var blockstate = world.getBlockState(pos);
35-
if (!blockstate.isAir() && user instanceof Player player) {
35+
if (!blockstate.isAir()) {
3636
BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, world.getBlockState(pos), world.getBlockEntity(pos), Sources.FLUID, player);
3737
}
3838
}
3939

40-
@Inject(method = "emptyContents", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/BucketItem;playEmptySound(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;)V"))
41-
private void logFluidPlace(LivingEntity user, Level world, BlockPos pos, BlockHitResult hitResult, CallbackInfoReturnable<Boolean> cir) {
42-
if (user instanceof Player player) {
43-
BlockPlaceCallback.EVENT.invoker().place(world, pos, this.content.defaultFluidState().createLegacyBlock(), null, player);
44-
} else {
45-
BlockPlaceCallback.EVENT.invoker().place(world, pos, this.content.defaultFluidState().createLegacyBlock(), null, Sources.REDSTONE);
46-
}
40+
@Inject(method = "emptyContents", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/BucketItem;playEmptySound(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;)V"))
41+
private void logFluidPlace(Player player, Level world, BlockPos pos, BlockHitResult blockHitResult, CallbackInfoReturnable<Boolean> cir) {
42+
BlockPlaceCallback.EVENT.invoker().place(world, pos, this.content.defaultFluidState().createLegacyBlock(), null, player);
4743
}
4844

4945
@Inject(
5046
method = "emptyContents",
5147
at = @At(
5248
value = "INVOKE",
53-
target = "Lnet/minecraft/world/item/BucketItem;playEmptySound(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;)V",
49+
target = "Lnet/minecraft/world/item/BucketItem;playEmptySound(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;)V",
5450
ordinal = 0
5551
)
5652
)
57-
private void logWaterlog(LivingEntity user, Level world, BlockPos pos, BlockHitResult hitResult, CallbackInfoReturnable<Boolean> cir, @Local BlockState blockState) {
58-
if (user instanceof Player player) {
59-
BlockChangeCallback.EVENT.invoker().changeBlock(
60-
world,
61-
pos,
62-
blockState,
63-
world.getBlockState(pos),
64-
world.getBlockEntity(pos),
65-
world.getBlockEntity(pos),
66-
player
67-
);
68-
} else {
69-
BlockChangeCallback.EVENT.invoker().changeBlock(
70-
world,
71-
pos,
72-
blockState,
73-
world.getBlockState(pos),
74-
world.getBlockEntity(pos),
75-
world.getBlockEntity(pos),
76-
Sources.REDSTONE
77-
); //TODO This is dumb. Make some sort of Source wrapper
78-
}
53+
private void logWaterlog(Player player, Level world, BlockPos pos, BlockHitResult blockHitResult, CallbackInfoReturnable<Boolean> cir, @Local BlockState blockState) {
54+
BlockChangeCallback.EVENT.invoker().changeBlock(
55+
world,
56+
pos,
57+
blockState,
58+
world.getBlockState(pos),
59+
world.getBlockEntity(pos),
60+
world.getBlockEntity(pos),
61+
player
62+
);
7963
}
8064

8165
@Inject(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;awardStat(Lnet/minecraft/stats/Stat;)V", ordinal = 0))

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

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

33
import com.github.quiltservertools.ledger.callbacks.BlockChangeCallback;
44
import com.github.quiltservertools.ledger.utility.Sources;
5+
import net.minecraft.world.level.Level;
56
import net.minecraft.world.level.block.state.BlockState;
67
import net.minecraft.world.level.block.entity.CampfireBlockEntity;
7-
import net.minecraft.world.item.crafting.CampfireCookingRecipe;
8-
import net.minecraft.world.item.crafting.RecipeManager;
9-
import net.minecraft.world.item.crafting.SingleRecipeInput;
10-
import net.minecraft.server.level.ServerLevel;
118
import net.minecraft.core.BlockPos;
129
import org.spongepowered.asm.mixin.Mixin;
1310
import org.spongepowered.asm.mixin.injection.At;
@@ -19,8 +16,8 @@ public abstract class CampfireBlockEntityMixin {
1916

2017
@Inject(method = "cookTick", at = @At(value = "INVOKE",
2118
target = "Lnet/minecraft/world/Containers;dropItemStack(Lnet/minecraft/world/level/Level;DDDLnet/minecraft/world/item/ItemStack;)V", shift = At.Shift.AFTER))
22-
private static void logCampfireRemoveItem(ServerLevel world, BlockPos pos, BlockState state, CampfireBlockEntity campfire, RecipeManager.CachedCheck<SingleRecipeInput, CampfireCookingRecipe> matchGetter, CallbackInfo ci) {
23-
BlockChangeCallback.EVENT.invoker().changeBlock(world, pos, state, world.getBlockState(pos), campfire, world.getBlockEntity(pos), Sources.REMOVE);
19+
private static void logCampfireRemoveItem(Level level, BlockPos pos, BlockState state, CampfireBlockEntity campfire, CallbackInfo ci) {
20+
BlockChangeCallback.EVENT.invoker().changeBlock(level, pos, state, level.getBlockState(pos), campfire, level.getBlockEntity(pos), Sources.REMOVE);
2421
}
2522

2623
}

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

Lines changed: 0 additions & 25 deletions
This file was deleted.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public abstract class DyeItemMixin {
2121
@Unique
2222
private CompoundTag oldEntityTags;
2323

24-
@Inject(method = "interactLivingEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/animal/sheep/Sheep;setColor(Lnet/minecraft/world/item/DyeColor;)V"))
24+
@Inject(method = "interactLivingEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/animal/Sheep;setColor(Lnet/minecraft/world/item/DyeColor;)V"))
2525
private void ledgerOldEntity(ItemStack stack, Player player, LivingEntity entity, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) {
2626
oldEntityTags = NbtUtils.INSTANCE.createNbt(entity);
2727
}
2828

29-
@Inject(method = "interactLivingEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/animal/sheep/Sheep;setColor(Lnet/minecraft/world/item/DyeColor;)V", shift = At.Shift.AFTER))
29+
@Inject(method = "interactLivingEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/animal/Sheep;setColor(Lnet/minecraft/world/item/DyeColor;)V", shift = At.Shift.AFTER))
3030
private void ledgerPlayerDyeSheep(ItemStack stack, Player player, LivingEntity entity, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) {
3131
EntityModifyCallback.EVENT.invoker().modify(player.level(), entity.blockPosition(), oldEntityTags, entity, stack, player, Sources.DYE);
3232
}

0 commit comments

Comments
 (0)