Skip to content

Commit

Permalink
fixed restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
Globox1997 committed Jan 11, 2024
1 parent e58a6f6 commit 07902d0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Added:
- Added spawner mob xp config option
### Fixed:
-
- Fixed armor switching
### Changed:
-
29 changes: 29 additions & 0 deletions src/main/java/net/levelz/mixin/misc/ScreenHandlerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,35 @@ public class ScreenHandlerMixin {
@Mutable
public DefaultedList<Slot> slots = DefaultedList.of();

@Inject(method = "internalOnSlotClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;canCombine(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z", ordinal = 0), cancellable = true)
private void internalOnSlotClickNewMixin(int slotIndex, int button, SlotActionType actionType, PlayerEntity player, CallbackInfo info) {
if (8 - MobEntity.getPreferredEquipmentSlot(cursorStack).getEntitySlotId() == slotIndex
&& (this.slots.get(slotIndex).toString().contains("PlayerScreenHandler") || this.slots.get(slotIndex).toString().contains("class_1723"))) {
if (cursorStack.getItem() instanceof ArmorItem armorItem) {
ArrayList<Object> levelList = LevelLists.customItemList;
try {
if (!levelList.isEmpty() && levelList.contains(Registries.ITEM.getId(armorItem).toString())) {
if (!PlayerStatsManager.playerLevelisHighEnough(player, LevelLists.customItemList, Registries.ITEM.getId(armorItem).toString(), true))
info.cancel();
} else {
levelList = LevelLists.armorList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, armorItem.getMaterial().getName().toLowerCase(), true))
info.cancel();
}
} catch (AbstractMethodError ignore) {
}
} else if (cursorStack.getItem() == Items.ELYTRA && !PlayerStatsManager.playerLevelisHighEnough(player, LevelLists.elytraList, null, true)) {
info.cancel();
} else if (!LevelLists.customItemList.isEmpty() && LevelLists.customItemList.contains(Registries.ITEM.getId(cursorStack.getItem()).toString())
&& !PlayerStatsManager.playerLevelisHighEnough(player, LevelLists.customItemList, Registries.ITEM.getId(cursorStack.getItem()).toString(), true))
info.cancel();
} else if (type == ScreenHandlerType.BREWING_STAND && slotIndex == 3 && !cursorStack.isEmpty()) {
if (PlayerStatsManager.listContainsItemOrBlock(player, Registries.ITEM.getRawId(cursorStack.getItem()), 2) && !player.isCreative()) {
info.cancel();
}
}
}

@Inject(method = "internalOnSlotClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/screen/ScreenHandler;setCursorStack(Lnet/minecraft/item/ItemStack;)V", ordinal = 2, shift = Shift.BEFORE), cancellable = true)
private void internalOnSlotClickMixin(int slotIndex, int button, SlotActionType actionType, PlayerEntity player, CallbackInfo info) {
if (8 - MobEntity.getPreferredEquipmentSlot(cursorStack).getEntitySlotId() == slotIndex
Expand Down

0 comments on commit 07902d0

Please sign in to comment.