Polygon command

未关闭
#2,863 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
java
领域
cli

调研方向

首先找到现有的 //cyl 和 //hcyl 命令实现,并将它们的选择和填充行为与拟议的 //poly 或 //hpoly 用法进行比较。检查提供的 minescript 示例,了解预期的多边形输入,然后定义并测试 pattern、sides、radius 和可选 fill 的行为,再认为该功能已经完成。

由索引模型根据 Issue 内容生成。

描述

status:pending type:feature-request
The Problem

Hard to make regular polygon shapes with similar functionality to //cyl or //hcyl

A Solution

//poly or //hpoly that takes a pattern, sides, radius, and optional fill.

Example python code:

angle_step = 360 / sides
angle = 180 / sides # Start angle to center the polygon

for i in range(sides):
x = int(radius * math.cos(math.radians(angle)))
z = int(radius * math.sin(math.radians(angle)))
"""
if i == 0:
f"//pos1 ~{x},~,~{z}" # relative to player
else:
f"//pos2 ~{x},~,~{z}" # relative to player
"""
angle += 360 / sides

Alternatives

Seperate commands for octagon, hexagon, pentagon would be too much of a hassle in my opinion.

Anything Else?

I am currently using minescript to make a custom poly command but I would like to see this implemented in the official worldedit and believe it would be fairly useful to most.
Here is my full minescript file if anyone is interested:
import minescript as m

# import system.pyj.minescript as m

import sys
import math

def usage():
m.echo("Usage: poly.py [fill]")
m.echo(" : Block pattern to use")
m.echo(" : Number of sides for the polygon")
m.echo(" : Radius of the polygon")
m.echo(" [fill]: Optional; if provided, the polygon will be filled")
sys.exit(1)

args = sys.argv
args.pop(0) # Remove script name

if len(args) == 0:
usage()

if args[0] in ("-h", "--help", "help"):
usage()

pattern = args[0]
sides = int(args[1])
radius = float(args[2])
fill = len(args) > 3 and args[3] is not None

m.execute("//sel cuboid") # Reset selection
m.execute("//sel poly")
pos = [math.floor(i) for i in m.player_position()]

# Compute angle increment
angle_step = 360 / sides
angle = 180 / sides # Start angle to center the polygon

for i in range(sides):
x = int(radius * math.cos(math.radians(angle)))
z = int(radius * math.sin(math.radians(angle)))

if i == 0:
    m.execute(f"//pos1 {x + pos[0]},{pos[1]},{z + pos[2]}")
else:
    m.execute(f"//pos2 {x + pos[0]},{pos[1]},{z + pos[2]}")

angle += angle_step

if fill:
m.execute(f"//set {pattern}")
else:
m.execute(f"//walls {pattern}")

主要语言
Java
星标
3.5k
派生
981
平均合并
2 天 15 小时
30 天内合并 PR
11

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

EngineHub/WorldEdit 的其他 Issue

查看 EngineHub/WorldEdit 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。