From c5c8976db289fd35e8412185537e23285004e829 Mon Sep 17 00:00:00 2001 From: HyCraftHD Date: Thu, 1 Aug 2024 18:32:38 +0200 Subject: [PATCH] Format --- .../useful_backpacks/block/FilterConfiguratorBlock.java | 2 +- .../useful_backpacks/component/ItemFilterComponent.java | 8 ++++---- .../useful_backpacks/component/TagFilterComponent.java | 8 ++++---- .../info/u_team/useful_backpacks/item/BackpackItem.java | 2 +- .../info/u_team/useful_backpacks/item/ItemFilterItem.java | 2 +- .../info/u_team/useful_backpacks/item/TagFilterItem.java | 2 +- .../integration/slot_mod/message/OpenBackpackMessage.java | 7 ++----- .../trinkets/render/TrinketsBackpackRenderer.java | 5 +---- .../u_team/useful_backpacks/mixin/ItemEntityMixin.java | 5 +---- .../useful_backpacks/event/ItemPickupEventHandler.java | 2 +- .../curios/impl/CuriosBackpackSlotModUtil.java | 1 + .../useful_backpacks/event/ItemPickupEventHandler.java | 2 +- 12 files changed, 19 insertions(+), 27 deletions(-) diff --git a/common/src/common/java/info/u_team/useful_backpacks/block/FilterConfiguratorBlock.java b/common/src/common/java/info/u_team/useful_backpacks/block/FilterConfiguratorBlock.java index b68e3127..6b96dd9e 100644 --- a/common/src/common/java/info/u_team/useful_backpacks/block/FilterConfiguratorBlock.java +++ b/common/src/common/java/info/u_team/useful_backpacks/block/FilterConfiguratorBlock.java @@ -31,7 +31,7 @@ public InteractionResult useWithoutItem(BlockState state, Level level, BlockPos if (level.isClientSide()) { return InteractionResult.SUCCESS; } else { - if (player instanceof ServerPlayer serverPlayer) { + if (player instanceof final ServerPlayer serverPlayer) { MenuUtil.openMenu(serverPlayer, state.getMenuProvider(level, pos), data -> { }, true); } diff --git a/common/src/common/java/info/u_team/useful_backpacks/component/ItemFilterComponent.java b/common/src/common/java/info/u_team/useful_backpacks/component/ItemFilterComponent.java index 32ae3ab5..1a7fa18b 100644 --- a/common/src/common/java/info/u_team/useful_backpacks/component/ItemFilterComponent.java +++ b/common/src/common/java/info/u_team/useful_backpacks/component/ItemFilterComponent.java @@ -61,12 +61,12 @@ public int hashCode() { @Override public boolean equals(Object object) { - if (this == object) + if (this == object) { return true; - if (object == null) - return false; - if (getClass() != object.getClass()) + } + if ((object == null) || (getClass() != object.getClass())) { return false; + } final ItemFilterComponent other = (ItemFilterComponent) object; return strict == other.strict && (stack == other.stack || stack != null && other.stack != null && stack.isEmpty() == other.stack.isEmpty() && ItemStack.isSameItemSameComponents(stack, other.stack)); } diff --git a/common/src/common/java/info/u_team/useful_backpacks/component/TagFilterComponent.java b/common/src/common/java/info/u_team/useful_backpacks/component/TagFilterComponent.java index b7fc9ced..212fef0d 100644 --- a/common/src/common/java/info/u_team/useful_backpacks/component/TagFilterComponent.java +++ b/common/src/common/java/info/u_team/useful_backpacks/component/TagFilterComponent.java @@ -54,12 +54,12 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) + } + if ((obj == null) || (getClass() != obj.getClass())) { return false; + } final TagFilterComponent other = (TagFilterComponent) obj; return Objects.equals(tag, other.tag); } diff --git a/common/src/common/java/info/u_team/useful_backpacks/item/BackpackItem.java b/common/src/common/java/info/u_team/useful_backpacks/item/BackpackItem.java index 95413376..1efbd0ec 100644 --- a/common/src/common/java/info/u_team/useful_backpacks/item/BackpackItem.java +++ b/common/src/common/java/info/u_team/useful_backpacks/item/BackpackItem.java @@ -59,7 +59,7 @@ public SimpleContainer getInventory(ServerPlayer player, ItemStack backpackStack @Override public void saveInventory(SimpleContainer inventory, ItemStack backpackStack) { - if (inventory instanceof BackpackInventory backpackInventory) { + if (inventory instanceof final BackpackInventory backpackInventory) { backpackInventory.writeItemStack(); } } diff --git a/common/src/common/java/info/u_team/useful_backpacks/item/ItemFilterItem.java b/common/src/common/java/info/u_team/useful_backpacks/item/ItemFilterItem.java index 9ea0ceb2..348d7d15 100644 --- a/common/src/common/java/info/u_team/useful_backpacks/item/ItemFilterItem.java +++ b/common/src/common/java/info/u_team/useful_backpacks/item/ItemFilterItem.java @@ -24,7 +24,7 @@ public class ItemFilterItem extends FilterItem { @Override public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { final ItemStack stack = player.getItemInHand(hand); - if (!level.isClientSide && player instanceof ServerPlayer serverPlayer) { + if (!level.isClientSide && player instanceof final ServerPlayer serverPlayer) { if (player.isShiftKeyDown()) { stack.set(UsefulBackpacksDataComponentTypes.ITEM_FILTER_COMPONENT.get(), ItemFilterComponent.EMPTY); } else { diff --git a/common/src/common/java/info/u_team/useful_backpacks/item/TagFilterItem.java b/common/src/common/java/info/u_team/useful_backpacks/item/TagFilterItem.java index 782d5874..206d0d83 100644 --- a/common/src/common/java/info/u_team/useful_backpacks/item/TagFilterItem.java +++ b/common/src/common/java/info/u_team/useful_backpacks/item/TagFilterItem.java @@ -24,7 +24,7 @@ public class TagFilterItem extends FilterItem { @Override public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { final ItemStack stack = player.getItemInHand(hand); - if (!level.isClientSide && player instanceof ServerPlayer serverPlayer) { + if (!level.isClientSide && player instanceof final ServerPlayer serverPlayer) { if (player.isShiftKeyDown()) { stack.set(UsefulBackpacksDataComponentTypes.TAG_FILTER_COMPONENT.get(), TagFilterComponent.EMPTY); } else { diff --git a/common/src/common_integration/java/info/u_team/useful_backpacks/integration/slot_mod/message/OpenBackpackMessage.java b/common/src/common_integration/java/info/u_team/useful_backpacks/integration/slot_mod/message/OpenBackpackMessage.java index 4f4e53b1..0f2b871c 100644 --- a/common/src/common_integration/java/info/u_team/useful_backpacks/integration/slot_mod/message/OpenBackpackMessage.java +++ b/common/src/common_integration/java/info/u_team/useful_backpacks/integration/slot_mod/message/OpenBackpackMessage.java @@ -19,14 +19,11 @@ private OpenBackpackMessage() { } public static void handle(OpenBackpackMessage message, NetworkContext context) { - if (!(context.getPlayer() instanceof ServerPlayer player)) { + if (!(context.getPlayer() instanceof final ServerPlayer player)) { return; } context.executeOnMainThread(() -> { - if (!player.isAlive()) { - return; - } - if (player.hasContainerOpen()) { + if (!player.isAlive() || player.hasContainerOpen()) { return; } final Optional curioBackpack = BackpackSlotModUtil.findBackpack(player); diff --git a/fabric/src/integration/java/info/u_team/useful_backpacks/integration/trinkets/render/TrinketsBackpackRenderer.java b/fabric/src/integration/java/info/u_team/useful_backpacks/integration/trinkets/render/TrinketsBackpackRenderer.java index a8d57086..119e72c3 100644 --- a/fabric/src/integration/java/info/u_team/useful_backpacks/integration/trinkets/render/TrinketsBackpackRenderer.java +++ b/fabric/src/integration/java/info/u_team/useful_backpacks/integration/trinkets/render/TrinketsBackpackRenderer.java @@ -21,10 +21,7 @@ public class TrinketsBackpackRenderer implements TrinketRenderer { @Override public void render(ItemStack stack, SlotReference slotReference, EntityModel model, PoseStack poseStack, MultiBufferSource bufferSource, int light, LivingEntity livingEntity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) { - if (livingEntity.hasItemInSlot(EquipmentSlot.CHEST)) { - return; - } - if (!(livingEntity instanceof AbstractClientPlayer player)) { + if (livingEntity.hasItemInSlot(EquipmentSlot.CHEST) || !(livingEntity instanceof final AbstractClientPlayer player)) { return; } diff --git a/fabric/src/main/java/info/u_team/useful_backpacks/mixin/ItemEntityMixin.java b/fabric/src/main/java/info/u_team/useful_backpacks/mixin/ItemEntityMixin.java index 238a75cd..0c773574 100644 --- a/fabric/src/main/java/info/u_team/useful_backpacks/mixin/ItemEntityMixin.java +++ b/fabric/src/main/java/info/u_team/useful_backpacks/mixin/ItemEntityMixin.java @@ -26,10 +26,7 @@ private ItemEntityMixin(EntityType type, Level level) { @Inject(method = "playerTouch", at = @At(value = "HEAD"), cancellable = true) private void usefulbackpacks$drop(Player player, CallbackInfo info) { final ItemEntity entity = ((ItemEntity) (Object) this); - if (entity.hasPickUpDelay()) { - return; - } - if (!(player instanceof ServerPlayer serverPlayer)) { + if (entity.hasPickUpDelay() || !(player instanceof final ServerPlayer serverPlayer)) { return; } diff --git a/forge/src/main/java/info/u_team/useful_backpacks/event/ItemPickupEventHandler.java b/forge/src/main/java/info/u_team/useful_backpacks/event/ItemPickupEventHandler.java index 2c7dfe3e..3f13420d 100644 --- a/forge/src/main/java/info/u_team/useful_backpacks/event/ItemPickupEventHandler.java +++ b/forge/src/main/java/info/u_team/useful_backpacks/event/ItemPickupEventHandler.java @@ -13,7 +13,7 @@ public class ItemPickupEventHandler { private static void onEntityItemPickup(EntityItemPickupEvent event) { final Player player = event.getEntity(); - if (!(player instanceof ServerPlayer serverPlayer)) { + if (!(player instanceof final ServerPlayer serverPlayer)) { return; } diff --git a/neoforge/src/integration/java/info/u_team/useful_backpacks/integration/curios/impl/CuriosBackpackSlotModUtil.java b/neoforge/src/integration/java/info/u_team/useful_backpacks/integration/curios/impl/CuriosBackpackSlotModUtil.java index 347e6b7f..88a68a40 100644 --- a/neoforge/src/integration/java/info/u_team/useful_backpacks/integration/curios/impl/CuriosBackpackSlotModUtil.java +++ b/neoforge/src/integration/java/info/u_team/useful_backpacks/integration/curios/impl/CuriosBackpackSlotModUtil.java @@ -11,6 +11,7 @@ public class CuriosBackpackSlotModUtil extends BackpackSlotModUtil { + @Override public Optional find(LivingEntity livingEntity) { return CuriosApi.getCuriosInventory(livingEntity).map(handler -> handler.findFirstCurio(stack -> stack.getItem() instanceof Backpack).map(SlotResult::stack)).orElse(Optional.empty()); } diff --git a/neoforge/src/main/java/info/u_team/useful_backpacks/event/ItemPickupEventHandler.java b/neoforge/src/main/java/info/u_team/useful_backpacks/event/ItemPickupEventHandler.java index c92163c7..104d1e14 100644 --- a/neoforge/src/main/java/info/u_team/useful_backpacks/event/ItemPickupEventHandler.java +++ b/neoforge/src/main/java/info/u_team/useful_backpacks/event/ItemPickupEventHandler.java @@ -12,7 +12,7 @@ public class ItemPickupEventHandler { private static void onEntityItemPickup(ItemEntityPickupEvent.Pre event) { final Player player = event.getPlayer(); - if (!(player instanceof ServerPlayer serverPlayer)) { + if (!(player instanceof final ServerPlayer serverPlayer)) { return; }