Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ detekt {
config.setFrom(rootProject.files("detekt.yml"))
}

tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
jvmTarget = JavaVersion.VERSION_21.toString()
}

gitHooks {
setHooks(
mapOf("pre-commit" to "detekt")
Expand Down
2 changes: 2 additions & 0 deletions gradle/gradle-daemon-jvm.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#This file is generated by updateDaemonJvm
toolchainVersion=21
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.item.BucketItem;
Expand All @@ -16,6 +15,7 @@
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -30,16 +30,20 @@ public abstract class BucketItemMixin {
private Fluid content;

@Inject(method = "emptyContents", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;destroyBlock(Lnet/minecraft/core/BlockPos;Z)Z"))
private void logFluidBreak(Player player, Level world, BlockPos pos, BlockHitResult blockHitResult, CallbackInfoReturnable<Boolean> cir) {
private void logFluidBreak(@Nullable Player player, Level world, BlockPos pos, @Nullable BlockHitResult blockHitResult, CallbackInfoReturnable<Boolean> cir) {
var blockstate = world.getBlockState(pos);
if (!blockstate.isAir()) {
BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, world.getBlockState(pos), world.getBlockEntity(pos), Sources.FLUID, player);
}
}

@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"))
private void logFluidPlace(Player player, Level world, BlockPos pos, BlockHitResult blockHitResult, CallbackInfoReturnable<Boolean> cir) {
BlockPlaceCallback.EVENT.invoker().place(world, pos, this.content.defaultFluidState().createLegacyBlock(), null, player);
private void logFluidPlace(@Nullable Player player, Level world, BlockPos pos, @Nullable BlockHitResult blockHitResult, CallbackInfoReturnable<Boolean> cir) {
if (player != null) {
BlockPlaceCallback.EVENT.invoker().place(world, pos, this.content.defaultFluidState().createLegacyBlock(), null, player);
} else {
BlockPlaceCallback.EVENT.invoker().place(world, pos, this.content.defaultFluidState().createLegacyBlock(), null, Sources.REDSTONE);
}
}

@Inject(
Expand All @@ -50,16 +54,28 @@ private void logFluidPlace(Player player, Level world, BlockPos pos, BlockHitRes
ordinal = 0
)
)
private void logWaterlog(Player player, Level world, BlockPos pos, BlockHitResult blockHitResult, CallbackInfoReturnable<Boolean> cir, @Local BlockState blockState) {
BlockChangeCallback.EVENT.invoker().changeBlock(
world,
pos,
blockState,
world.getBlockState(pos),
world.getBlockEntity(pos),
world.getBlockEntity(pos),
player
);
private void logWaterlog(@Nullable Player player, Level world, BlockPos pos, @Nullable BlockHitResult blockHitResult, CallbackInfoReturnable<Boolean> cir, @Local BlockState blockState) {
if (player != null) {
BlockChangeCallback.EVENT.invoker().changeBlock(
world,
pos,
blockState,
world.getBlockState(pos),
world.getBlockEntity(pos),
world.getBlockEntity(pos),
player
);
} else {
BlockChangeCallback.EVENT.invoker().changeBlock(
world,
pos,
blockState,
world.getBlockState(pos),
world.getBlockEntity(pos),
world.getBlockEntity(pos),
Sources.REDSTONE
);
}
}

@Inject(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;awardStat(Lnet/minecraft/stats/Stat;)V", ordinal = 0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ private static void logPutBook(Entity user, Level world, BlockPos pos, BlockStat
ItemInsertCallback.EVENT.invoker().insert(blockEntity.getBook(), pos, (ServerLevel) world, Sources.PLAYER, (ServerPlayer) user);
}

@Inject(method = "openScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;openMenu(Lnet/minecraft/world/MenuProvider;)Ljava/util/OptionalInt;"))
@Inject(method = "openScreen", at = @At("HEAD"))
public void storeLectern(Level world, BlockPos pos, Player player, CallbackInfo ci) {
PlayerLecternHook.getActiveHandlers().put(player, world.getBlockEntity(pos));
if (world.getBlockEntity(pos) instanceof LecternBlockEntity blockEntity) {
PlayerLecternHook.getActiveHandlers().put(player, blockEntity);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class LecternMenuMixin {
public void logPickBook(Player player, int id, CallbackInfoReturnable<Boolean> cir, @Local ItemStack itemStack) {
ServerPlayer serverPlayer = (ServerPlayer) player;
BlockEntity blockEntity = PlayerLecternHook.getActiveHandlers().get(player);
if (blockEntity == null) return;
ItemRemoveCallback.EVENT.invoker().remove(itemStack, blockEntity.getBlockPos(), serverPlayer.serverLevel(), Sources.PLAYER, serverPlayer);
}
}