From 7c3e310ca2e90702aa819d8a8b96767c6aa01374 Mon Sep 17 00:00:00 2001 From: pietru Date: Wed, 2 Apr 2025 23:23:41 +0200 Subject: [PATCH] add continious rotation --- .../pietru/cookie_utils/mixins/BlockPlaceMixin.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pietru/cookie_utils/mixins/BlockPlaceMixin.java b/src/main/java/net/pietru/cookie_utils/mixins/BlockPlaceMixin.java index cfac0ca..69093c9 100644 --- a/src/main/java/net/pietru/cookie_utils/mixins/BlockPlaceMixin.java +++ b/src/main/java/net/pietru/cookie_utils/mixins/BlockPlaceMixin.java @@ -5,7 +5,9 @@ import finalforeach.cosmicreach.accounts.Account; import finalforeach.cosmicreach.blocks.BlockPosition; import finalforeach.cosmicreach.blocks.BlockState; import finalforeach.cosmicreach.blocks.BlockStateMissing; +import finalforeach.cosmicreach.entities.player.Player; import finalforeach.cosmicreach.items.ItemMergeStrategy; +import finalforeach.cosmicreach.items.ItemSlot; import finalforeach.cosmicreach.items.ItemStack; import finalforeach.cosmicreach.networking.NetworkIdentity; import finalforeach.cosmicreach.networking.packets.MessagePacket; @@ -29,6 +31,8 @@ public class BlockPlaceMixin { BlockPosition blockPos; @Shadow BlockState targetBlockState; + @Shadow + byte itemSlotNum; @Inject(method = "handle", at = @At("HEAD"), cancellable = true) private void event_block_place(CallbackInfo ci, @Local NetworkIdentity identity, @Local ChannelHandlerContext ctx){ @@ -48,8 +52,12 @@ public class BlockPlaceMixin { if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_edit_block(temp,"place",account.getUniqueId())) { ci.cancel(); - if (!identity.getPlayer().gamemode.hasInfiniteItems()) - identity.getPlayer().inventory.merge(new ItemStack(targetBlockState.getItem()), ItemMergeStrategy.ONLY_ONE_SLOT); + Player player = identity.getPlayer(); + if (!player.gamemode.hasInfiniteItems()){ + ItemSlot itemSlot = player.inventory.getSlot(this.itemSlotNum); + itemSlot.setDirty(true); + player.inventory.syncDirtySlots(0, identity); + } MessagePacket packet = new MessagePacket("[Server] " + (is_not_reloading ? "Sorry, but this area is under protection." : "Sorry but you can't do this action right now. [Config Reload In Progress]")); packet.setupAndSend(ctx);