diff --git a/src/main/java/carpet/commands/PlayerCommand.java b/src/main/java/carpet/commands/PlayerCommand.java index d1e1bd77..db8f5f0a 100644 --- a/src/main/java/carpet/commands/PlayerCommand.java +++ b/src/main/java/carpet/commands/PlayerCommand.java @@ -58,6 +58,9 @@ public class PlayerCommand .then(makeActionCommand("dropStack", EntityPlayerActionPack.ActionType.DROP_STACK)) .then(makeDropCommand("dropStack", true)) .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("shadow"). executes(PlayerCommand::shadow)) .then(literal("mount").executes(manipulation(ap -> ap.mount(true))) diff --git a/src/main/java/carpet/helpers/EntityPlayerActionPack.java b/src/main/java/carpet/helpers/EntityPlayerActionPack.java index af934aba..e1616b54 100644 --- a/src/main/java/carpet/helpers/EntityPlayerActionPack.java +++ b/src/main/java/carpet/helpers/EntityPlayerActionPack.java @@ -10,6 +10,7 @@ import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.vehicle.BoatEntity; import net.minecraft.entity.vehicle.MinecartEntity; import net.minecraft.item.ItemStack; +import net.minecraft.network.packet.s2c.play.HeldItemChangeS2CPacket; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; 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 { USE(true) diff --git a/src/main/resources/assets/carpet/scripts/overlay.sc b/src/main/resources/assets/carpet/scripts/overlay.sc index a78aa78f..ed05761e 100644 --- a/src/main/resources/assets/carpet/scripts/overlay.sc +++ b/src/main/resources/assets/carpet/scripts/overlay.sc @@ -36,22 +36,15 @@ __config() -> 'slime_chunks' -> ['__toggle', 'slime_chunks', 'chunks'], 'portal coordinates' -> ['__toggle', 'coords', 'portals'], 'portal links' -> ['__toggle', 'links', 'portals'], - ' following ' -> ['display_shape', [null,0xffffffff], true], - ' at ' -> ['display_shape', [null,0xffffffff], false], - ' following ' -> ['display_shape', true], - ' at ' -> ['display_shape', false], + ' following ' -> ['display_shape', [null,0xffffffff], true], + ' at ' -> ['display_shape', [null,0xffffffff], false], + ' following ' -> ['display_shape', true], + ' at ' -> ['display_shape', false], ' clear' -> 'clear_shape', 'clear' -> 'clear', }, 'arguments' -> { - 'structure' -> {'type' -> 'term', 'suggest' -> [ - 'monument', 'fortress', 'mansion', 'jungle_pyramid', - 'desert_pyramid', 'endcity', 'igloo', 'shipwreck', - 'swamp_hut', 'stronghold', 'ocean_ruin', 'buried_treasure', - 'pillager_outpost', 'mineshaft', 'village', 'nether_fossil', - 'bastion_remnant', 'ruined_portal' - ]}, - 'player' -> {'type' -> 'players', 'single' -> true}, + 'structure' -> {'type' -> 'term', 'suggest' -> plop():'structures' }, 'radius' -> {'type' -> 'int', 'min' -> 0, 'max' -> 1024, 'suggest' -> [128, 24, 32]}, 'shape' -> {'type' -> 'term', 'options' -> keys(global_shapes) }, 'color' -> {'type' -> 'teamcolor'} @@ -59,29 +52,30 @@ __config() -> }; -display_shape(shape, r, player, color, following) -> +display_shape(shape, r, entities, color, following) -> ( - - player = player(player); - if (!player, return()); - if (shape == 'sphere', - shape_config = { - 'center' -> if(following, [0,0,0], pos(player)), - 'radius' -> r - } - , shape == 'box', - shape_config = { - 'from' -> if(following, [-r,-r,-r], pos(player)-r), - 'to' -> if(following, [r,r,r], pos(player)+r) - } - ); - if (shape_config, - if (following, shape_config:'follow' = player); - shape_config:'fill' = color:1 - 200; - shape_config:'color' = color:1; - shape_config:'line' = 5; - draw_shape(shape, 72000, shape_config); - global_shapes:shape += shape_config; + thicc = max(1, floor(6-length(entities)/2)); + fillc = 250 - 100/(length(entities)+1); + for (entities, + if (shape == 'sphere', + shape_config = { + 'center' -> if(following, [0,0,0], pos(_)), + 'radius' -> r + } + , shape == 'box', + shape_config = { + 'from' -> if(following, [-r,-r,-r], pos(_)-r), + 'to' -> if(following, [r,r,r], pos(_)+r) + } + ); + if (shape_config, + if (following, shape_config:'follow' = _); + shape_config:'fill' = color:1 - fillc; + shape_config:'color' = color:1; + shape_config:'line' = thicc; + draw_shape(shape, 72000, shape_config); + global_shapes:shape += shape_config; + ) ) );