mirror of
https://github.com/TheWhiteDog9487/RandomTeleporter.git
synced 2025-09-15 20:36:58 +00:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
d47907cdf4 | |||
8c55311f27 | |||
35ac4dd842 | |||
34ea09dfd9 | |||
ad014a2b1b | |||
4de867d6aa | |||
9770b72448 | |||
66a1529132 | |||
96a69f3262 |
9
.gitattributes
vendored
Normal file
9
.gitattributes
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# https://help.github.com/articles/dealing-with-line-endings/
|
||||
#
|
||||
# Linux start script should use lf
|
||||
/gradlew text eol=lf
|
||||
|
||||
# These are Windows script files and should use crlf
|
||||
*.bat text eol=crlf
|
||||
|
37
.github/workflows/build.yml
vendored
Normal file
37
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
# Automatically build the project and run any configured tests for every push
|
||||
# and submitted pull request. This can help catch issues that only occur on
|
||||
# certain platforms or Java versions, and provides a first line of defence
|
||||
# against bad commits.
|
||||
|
||||
name: build
|
||||
on: [pull_request, push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
# Use these Java versions
|
||||
java: [
|
||||
21, # Current Java LTS
|
||||
]
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: validate gradle wrapper
|
||||
uses: gradle/wrapper-validation-action@v2
|
||||
- name: setup jdk ${{ matrix.java }}
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
distribution: 'microsoft'
|
||||
- name: make gradle wrapper executable
|
||||
run: chmod +x ./gradlew
|
||||
- name: build
|
||||
run: ./gradlew build
|
||||
- name: capture build artifacts
|
||||
if: ${{ matrix.java == '21' }} # Only upload artifacts built from latest java
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Artifacts
|
||||
path: build/libs/
|
@@ -1,9 +1,9 @@
|
||||
plugins {
|
||||
id("fabric-loom") version "1.9-SNAPSHOT"
|
||||
id("fabric-loom") version "1.11-SNAPSHOT"
|
||||
id("maven-publish")
|
||||
}
|
||||
|
||||
version = "${project.extra["mod_version"]}"
|
||||
version = project.extra["mod_version"] as String
|
||||
group = project.extra["maven_group"] as String
|
||||
|
||||
base {
|
||||
|
@@ -4,24 +4,18 @@ org.gradle.parallel=true
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.21.4
|
||||
yarn_mappings=1.21.4+build.1
|
||||
loader_version=0.16.9
|
||||
minecraft_version=1.21.8
|
||||
yarn_mappings=1.21.8+build.1
|
||||
loader_version=0.16.14
|
||||
|
||||
# Mod Properties
|
||||
mod_version=0.3.5
|
||||
mod_version=0.3.6
|
||||
maven_group=xyz.thewhitedog9487
|
||||
archives_base_name=RandomTeleporter
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.110.5+1.21.4
|
||||
fabric_version=0.129.0+1.21.8
|
||||
|
||||
# https://modrinth.com/mod/modmenu/versions
|
||||
# https://maven.terraformersmc.com/releases/com/terraformersmc/modmenu
|
||||
modmenu_version=13.0.0-beta.1
|
||||
|
||||
# loom_libraries_base=https://bmclapi2.bangbang93.com/maven/
|
||||
# loom_resources_base=https://bmclapi2.bangbang93.com/assets/
|
||||
# loom_version_manifests=https://bmclapi2.bangbang93.com/mc/game/version_manifest.json
|
||||
# loom_experimental_versions=https://maven.fabricmc.net/net/minecraft/experimental_versions.json
|
||||
# loom_fabric_repository=https://repository.hanbings.io/proxy/
|
||||
modmenu_version=15.0.0-beta.3
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||
distributionUrl=https://services.gradle.org/distributions/gradle-8.14-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
@@ -221,14 +221,27 @@ public class CommandRegister {
|
||||
if (Radius == null){Radius = (int) (WorldBorder - 1e4);}
|
||||
// ↑ 远离世界边界
|
||||
Radius = Math.abs(Radius);
|
||||
int Coordinate_X;
|
||||
int Coordinate_Z;
|
||||
if (Origin == null){
|
||||
Coordinate_X = new SplittableRandom().nextInt(-Radius, Radius);
|
||||
Coordinate_Z = new SplittableRandom().nextInt(-Radius, Radius);}
|
||||
else{
|
||||
Coordinate_X = new SplittableRandom().nextInt((int) Origin.x - Radius, (int) Origin.x + Radius);
|
||||
Coordinate_Z = new SplittableRandom().nextInt((int) Origin.y - Radius, (int) Origin.y + Radius);}
|
||||
int Coordinate_X = 0;
|
||||
int Coordinate_Z = 0;
|
||||
try {
|
||||
if (Origin == null){
|
||||
Coordinate_X = new SplittableRandom().nextInt(-Radius, Radius);
|
||||
Coordinate_Z = new SplittableRandom().nextInt(-Radius, Radius);}
|
||||
else{
|
||||
Coordinate_X = new SplittableRandom().nextInt((int) Origin.x - Radius, (int) Origin.x + Radius);
|
||||
Coordinate_Z = new SplittableRandom().nextInt((int) Origin.y - Radius, (int) Origin.y + Radius);}}
|
||||
catch (IllegalArgumentException e) {
|
||||
// 半径为零
|
||||
if (Origin == null) {
|
||||
Source.sendFeedback(()->{ return Text.translatableWithFallback("warning.radius_equal_zero_no_target", "由于你设置的随机半径为0,并且未设置随机中心点坐标,因此什么都不会发生"); },true);
|
||||
return -1;}
|
||||
else {
|
||||
Coordinate_X = (int) Origin.x;
|
||||
Coordinate_Z = (int) Origin.y;
|
||||
int finalCoordinate_X1 = Coordinate_X;
|
||||
int finalCoordinate_Z1 = Coordinate_Z;
|
||||
// ↑ "lambda 表达式中使用的变量应为 final 或有效 final"
|
||||
Source.sendFeedback(()->{ return Text.translatableWithFallback("warning.radius_equal_zero", "警告:由于你设置的随机半径为0,因此在选择出合适高度之后将直接把你传送至%d %d", finalCoordinate_X1, finalCoordinate_Z1); },true);}}
|
||||
int Coordinate_Y = 320;
|
||||
for (var CurrentBlock = Source.getWorld().getBlockState(new BlockPos(Coordinate_X, Coordinate_Y, Coordinate_Z)).getBlock();
|
||||
// 从世界顶层往下找,直到遇到一个非空气方块
|
||||
@@ -254,9 +267,11 @@ public class CommandRegister {
|
||||
Coordinate_Y++;
|
||||
// ↑ 高一层,人别站在土里了
|
||||
entity.teleport(Source.getWorld(),Coordinate_X + 0.5, Coordinate_Y, Coordinate_Z + 0.5, new HashSet<>(), entity.getYaw(), entity.getPitch(), false);
|
||||
int finalCoordinate_X = Coordinate_X;
|
||||
int finalCoordinate_Y = Coordinate_Y;
|
||||
int finalCoordinate_Z = Coordinate_Z;
|
||||
// ↑ "lambda 表达式中使用的变量应为 final 或有效 final"
|
||||
final var FeedbackFallbackString = String.format("已将玩家%s传送到%d %d %d", entity.getName().getString(), Coordinate_X, finalCoordinate_Y, Coordinate_Z);
|
||||
Source.sendFeedback(()->{ return Text.translatableWithFallback("info.success", FeedbackFallbackString, entity.getName(), Coordinate_X, finalCoordinate_Y, Coordinate_Z); },true);
|
||||
Source.sendFeedback(()->{ return Text.translatableWithFallback("info.success", FeedbackFallbackString, entity.getName(), finalCoordinate_X, finalCoordinate_Y, finalCoordinate_Z); },true);
|
||||
return 16;}
|
||||
}
|
@@ -3,5 +3,7 @@
|
||||
"modmenu.descriptionTranslation.randomteleporter": "Added two commands for random teleportation",
|
||||
"info.success": "Teleported %s to %d %d %d",
|
||||
"error.no_target": "There is no teleported target, and the teleported player ID is explicitly specified when executed by a non-player object",
|
||||
"warning.radius_equal_zero": "Warning: Since you set a random radius of 0, selecting the right height will teleport you directly to %d %d",
|
||||
"warning.radius_equal_zero_no_target": "Warning: Since you set a random radius of 0 and you don't set a random center point coordinates, nothing happens",
|
||||
"bilibili": "Bilibili"
|
||||
}
|
@@ -3,5 +3,7 @@
|
||||
"modmenu.descriptionTranslation.randomteleporter": "增加了两个用于随机传送的命令",
|
||||
"info.success": "已将玩家%s传送到%d %d %d",
|
||||
"error.no_target": "不存在被传送目标,由非玩家物体执行命令时请显式指定被传送玩家ID",
|
||||
"warning.radius_equal_zero": "警告:由于你设置的随机半径为0,因此在选择出合适高度之后将直接把你传送至%d %d",
|
||||
"warning.radius_equal_zero_no_target": "警告:由于你设置的随机半径为0,并且未设置随机中心点坐标,因此什么都不会发生",
|
||||
"bilibili": "TheWhiteDog9487的哔哩哔哩主页"
|
||||
}
|
@@ -27,10 +27,10 @@
|
||||
}
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.16.9",
|
||||
"minecraft": "1.21.4",
|
||||
"fabricloader": ">=0.16.14",
|
||||
"minecraft": "1.21.8",
|
||||
"java": ">=21",
|
||||
"fabric-api": ">=0.110.5"
|
||||
"fabric-api": ">=0.129.0"
|
||||
},
|
||||
"suggests": {
|
||||
"another-mod": "*"
|
||||
|
Reference in New Issue
Block a user