This commit is contained in:
parent
3edd1e5afd
commit
7c3e310ca2
1 changed files with 10 additions and 2 deletions
|
@ -5,7 +5,9 @@ import finalforeach.cosmicreach.accounts.Account;
|
||||||
import finalforeach.cosmicreach.blocks.BlockPosition;
|
import finalforeach.cosmicreach.blocks.BlockPosition;
|
||||||
import finalforeach.cosmicreach.blocks.BlockState;
|
import finalforeach.cosmicreach.blocks.BlockState;
|
||||||
import finalforeach.cosmicreach.blocks.BlockStateMissing;
|
import finalforeach.cosmicreach.blocks.BlockStateMissing;
|
||||||
|
import finalforeach.cosmicreach.entities.player.Player;
|
||||||
import finalforeach.cosmicreach.items.ItemMergeStrategy;
|
import finalforeach.cosmicreach.items.ItemMergeStrategy;
|
||||||
|
import finalforeach.cosmicreach.items.ItemSlot;
|
||||||
import finalforeach.cosmicreach.items.ItemStack;
|
import finalforeach.cosmicreach.items.ItemStack;
|
||||||
import finalforeach.cosmicreach.networking.NetworkIdentity;
|
import finalforeach.cosmicreach.networking.NetworkIdentity;
|
||||||
import finalforeach.cosmicreach.networking.packets.MessagePacket;
|
import finalforeach.cosmicreach.networking.packets.MessagePacket;
|
||||||
|
@ -29,6 +31,8 @@ public class BlockPlaceMixin {
|
||||||
BlockPosition blockPos;
|
BlockPosition blockPos;
|
||||||
@Shadow
|
@Shadow
|
||||||
BlockState targetBlockState;
|
BlockState targetBlockState;
|
||||||
|
@Shadow
|
||||||
|
byte itemSlotNum;
|
||||||
|
|
||||||
@Inject(method = "handle", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "handle", at = @At("HEAD"), cancellable = true)
|
||||||
private void event_block_place(CallbackInfo ci, @Local NetworkIdentity identity, @Local ChannelHandlerContext ctx){
|
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())) {
|
if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_edit_block(temp,"place",account.getUniqueId())) {
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
if (!identity.getPlayer().gamemode.hasInfiniteItems())
|
Player player = identity.getPlayer();
|
||||||
identity.getPlayer().inventory.merge(new ItemStack(targetBlockState.getItem()), ItemMergeStrategy.ONLY_ONE_SLOT);
|
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]"));
|
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);
|
packet.setupAndSend(ctx);
|
||||||
|
|
Loading…
Reference in a new issue