| Total Complexity | 1 |
| Total Lines | 11 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package de.pewpewproject.lasertag.mixin; |
||
| 16 | @Mixin(Slot.class) |
||
| 17 | public abstract class SlotMixin { |
||
| 18 | |||
| 19 | @Inject(method = "canTakeItems(Lnet/minecraft/entity/player/PlayerEntity;)Z", at = @At("HEAD"), cancellable = true) |
||
| 20 | private void onCanTakeItems(PlayerEntity playerEntity, CallbackInfoReturnable<Boolean> cir) { |
||
| 21 | |||
| 22 | // Get the item stack of the slot |
||
| 23 | var itemStack = ((Slot)(Object)this).getStack(); |
||
| 24 | |||
| 25 | // Player can always take it of if he is in creative mode. But otherwise can't take of the lasertag vest. |
||
| 26 | cir.setReturnValue(playerEntity.isCreative() || !itemStack.isOf(Items.LASERTAG_VEST)); |
||
| 27 | } |
||
| 29 |