package com.thebrokenrail.slightlyvanilla.mixin; import com.thebrokenrail.slightlyvanilla.SlightlyVanilla; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.LockableContainerBlockEntity; import net.minecraft.block.entity.LootableContainerBlockEntity; import net.minecraft.entity.player.PlayerEntity; 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.CallbackInfoReturnable; @SuppressWarnings("unused") @Mixin(LootableContainerBlockEntity.class) public abstract class MixinLootableContainerBlockEntity extends LockableContainerBlockEntity { protected MixinLootableContainerBlockEntity(BlockEntityType blockEntityType) { super(blockEntityType); } @Inject(at = @At("HEAD"), method = "checkUnlocked", cancellable = true) public void checkUnlocked(PlayerEntity player, CallbackInfoReturnable info) { if (SlightlyVanilla.getConfig().openLootChestsInSpectatorMode) { info.setReturnValue(super.checkUnlocked(player)); } } }