Skip to content

Commit

Permalink
Add minimum OP level
Browse files Browse the repository at this point in the history
  • Loading branch information
Jai A committed Jul 7, 2020
1 parent b27130b commit fa97f7b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public static class MainSettings {
@ConfigEntry.Gui.Tooltip
public boolean enableGraveLooting = false;

@ConfigEntry.Gui.Tooltip
public int minimumOpLevelToLoot = 4;

@ConfigEntry.Gui.Tooltip
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
public GravestoneRetrievalType retrievalType = GravestoneRetrievalType.ON_STEP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ public class ClientPlayerInteractionManagerMixin {

@Shadow @Final private ClientPlayNetworkHandler networkHandler;

@Shadow @Final private MinecraftClient client;

@Inject(method = "breakBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;onBreak(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/entity/player/PlayerEntity;)V"), locals = LocalCapture.CAPTURE_FAILSOFT, cancellable = true)
private void breakBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir, World world, BlockState blockState, Block block) {
BlockEntity blockEntity = world.getBlockEntity(pos);

if(blockEntity instanceof GravestoneBlockEntity) {
if(this.client.player.hasPermissionLevel(GravestonesConfig.getConfig().mainSettings.minimumOpLevelToLoot)) return;

GravestoneBlockEntity gravestoneBlockEntity = (GravestoneBlockEntity) blockEntity;

if(GravestonesConfig.getConfig().mainSettings.retrievalType != GravestoneRetrievalType.ON_BREAK && gravestoneBlockEntity.getGraveOwner() != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class ServerPlayerInteractionManagerMixin {
@Inject(method = "tryBreakBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;onBreak(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/entity/player/PlayerEntity;)V"), locals = LocalCapture.CAPTURE_FAILSOFT, cancellable = true)
private void onBreakBlockBlock(BlockPos blockPos, CallbackInfoReturnable<Boolean> cir, BlockState blockState, BlockEntity blockEntity, Block block) {
if(blockEntity instanceof GravestoneBlockEntity) {
if(this.player.hasPermissionLevel(GravestonesConfig.getConfig().mainSettings.minimumOpLevelToLoot)) return;

GravestoneBlockEntity gravestoneBlockEntity = (GravestoneBlockEntity) blockEntity;

if(GravestonesConfig.getConfig().mainSettings.retrievalType != GravestoneRetrievalType.ON_BREAK && gravestoneBlockEntity.getGraveOwner() != null)
Expand Down

0 comments on commit fa97f7b

Please sign in to comment.