player selects hotbar slot, fixes #557
This commit is contained in:
1 parent
33bf24fa86
commit
4b0fd8296c
2 files changed
+10
No files matched your search
@@ -58,6 +58,9 @@ public class PlayerCommand
|
|||||||
.then(makeActionCommand("dropStack", EntityPlayerActionPack.ActionType.DROP_STACK))
|
.then(makeActionCommand("dropStack", EntityPlayerActionPack.ActionType.DROP_STACK))
|
||||||
.then(makeDropCommand("dropStack", true))
|
.then(makeDropCommand("dropStack", true))
|
||||||
.then(makeActionCommand("swapHands", EntityPlayerActionPack.ActionType.SWAP_HANDS))
|
.then(makeActionCommand("swapHands", EntityPlayerActionPack.ActionType.SWAP_HANDS))
|
||||||
|
.then(literal("hotbar")
|
||||||
|
.then(argument("slot", IntegerArgumentType.integer(1, 9))
|
||||||
|
.executes(c -> manipulate(c, ap -> ap.setSlot(IntegerArgumentType.getInteger(c, "slot"))))))
|
||||||
.then(literal("kill").executes(PlayerCommand::kill))
|
.then(literal("kill").executes(PlayerCommand::kill))
|
||||||
.then(literal("shadow"). executes(PlayerCommand::shadow))
|
.then(literal("shadow"). executes(PlayerCommand::shadow))
|
||||||
.then(literal("mount").executes(manipulation(ap -> ap.mount(true)))
|
.then(literal("mount").executes(manipulation(ap -> ap.mount(true)))
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import net.minecraft.entity.player.PlayerInventory;
|
|||||||
import net.minecraft.entity.vehicle.BoatEntity;
|
import net.minecraft.entity.vehicle.BoatEntity;
|
||||||
import net.minecraft.entity.vehicle.MinecartEntity;
|
import net.minecraft.entity.vehicle.MinecartEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.network.packet.s2c.play.HeldItemChangeS2CPacket;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
|
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
@@ -276,6 +277,12 @@ public class EntityPlayerActionPack
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSlot(int slot)
|
||||||
|
{
|
||||||
|
player.inventory.selectedSlot = slot-1;
|
||||||
|
player.networkHandler.sendPacket(new HeldItemChangeS2CPacket(slot-1));
|
||||||
|
}
|
||||||
|
|
||||||
public enum ActionType
|
public enum ActionType
|
||||||
{
|
{
|
||||||
USE(true)
|
USE(true)
|
||||||
|
|||||||
Reference in new issue
Block a user