1 Commits
1.21 ... 1.19.1

Author SHA1 Message Date
3434b66c93 0.2.5
突然发现Ved3d类型的方法里有一个计算两点间距离的,那我就把我自己的工具库撤了。
然后我把命令权限等级从4下降到了2,和原版的/tp同步。
(我记得原版的tp是4级啊?我最早还去源代码里看了一眼,咋回事呢?
传送过去生成的保护平台,现在是3x3的玻璃而不是1x1的石头,而且玩家会站在平台的正中心。
例行更新Fabric API和Fabric Loader
2024-03-20 10:08:57 +08:00
11 changed files with 42 additions and 36 deletions

View File

@@ -73,10 +73,6 @@
1. 服务器需要安装
2. 客户端不需要
**注意情况2和3虽然其他玩家不需要安装本模组就能使用功能。但是由于命令执行后的反馈结果文字使用了翻译如果其他玩家没有安装模组会导致显示不正常玩家会直接看到翻译键而不是对应的文字。
因此,虽然可以但不建议其他人不安装。
能安装的话还是都装一下吧。**
# 一些小彩蛋
你可以使用 /随机传送 来替代 /rtp
没错Minecraft的命令是可以存在非ASCII字符的所以我就整了一个

View File

@@ -1,9 +1,9 @@
plugins {
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'maven-publish'
}
version = project.mod_version + " mc$project.minecraft_version"
version = project.mod_version
group = project.maven_group
base {
@@ -54,7 +54,7 @@ processResources {
}
tasks.withType(JavaCompile).configureEach {
it.options.release = 21
it.options.release = 17
}
java {
@@ -63,8 +63,8 @@ java {
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
jar {

View File

@@ -4,20 +4,20 @@ org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21
yarn_mappings=1.21+build.9
loader_version=0.15.11
minecraft_version=1.19.1
yarn_mappings=1.19.1+build.6
loader_version=0.15.7
# Mod Properties
mod_version=0.3.1
mod_version=0.2.5
maven_group=xyz.thewhitedog9487
archives_base_name=randomteleporter
# Dependencies
fabric_version=0.102.0+1.21
fabric_version=0.58.5+1.19.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/
loom_fabric_repository=https://repository.hanbings.io/proxy/

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

View File

@@ -1,7 +1,7 @@
{
"required": false,
"package": "xyz.thewhitedog9487.mixin.client",
"compatibilityLevel": "JAVA_21",
"compatibilityLevel": "JAVA_17",
"client": [
],

View File

@@ -12,14 +12,16 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import org.jetbrains.annotations.Nullable;
import java.util.HashSet;
import java.util.SplittableRandom;
import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.server.command.CommandManager.literal;
public class CommandRegister {
final static long WorldBorder = (long) 2.9e7;
// https://zh.minecraft.wiki/w/%E4%B8%96%E7%95%8C%E7%95%8C%E9%99%90
// https://minecraft.wiki/w/World_boundary
final static long WorldBoundary = (long) 2.9e7;
static byte Retry = 0;
static byte PermissionLevel = 2;
public static void Register(String Name){
// /rtp
@@ -166,9 +168,9 @@ public class CommandRegister {
static int execute_command(ServerCommandSource Source, @Nullable Long Radius, @Nullable Entity Player, @Nullable Vec3d Origin){
Entity entity = Player == null ? Source.getPlayer() : Player;
if (entity == null) {
Source.sendFeedback(()->{ return Text.translatable("error.not_player"); }, true);
Source.sendFeedback(Text.translatable("error.twd.rtp.not_player"), true);
return -1;}
if (Radius == null){Radius = WorldBorder - (long) 1e4;}
if (Radius == null){Radius = WorldBoundary - (long) 1e4;}
Radius = Math.abs(Radius);
long Coordinate_X;
long Coordinate_Z;
@@ -192,11 +194,18 @@ public class CommandRegister {
// if ( String.valueOf(entity.getWorld().getBiome(new BlockPos(Math.toIntExact(Coordinate_X), Coordinate_Y, Math.toIntExact(Coordinate_Z))).getKey()).equals("minecraft:the_void") ) {
// Coordinate_Y++;}
Coordinate_Y++;
entity.teleport(Source.getWorld(),Coordinate_X + 0.5, Coordinate_Y, Coordinate_Z + 0.5, new HashSet<>(), entity.getYaw(), entity.getPitch());
Vec3d Coordinate = new Vec3d(Coordinate_X, Coordinate_Y, Coordinate_Z);
if (Radius == WorldBoundary && Retry < 126 && entity.getPos().distanceTo(Coordinate) < 1e5){
Retry++;
execute_command(Source, Radius,null, Origin);
return 0;}
if (Retry >= 126){
Source.sendFeedback(Text.translatable("warning.twd.rtp.retry"), true);}
entity.teleport(Coordinate_X + 0.5, Coordinate_Y, Coordinate_Z + 0.5);
final long FinalCoordinate_X = Coordinate_X;
final int FinalCoordinate_Y = Coordinate_Y;
final long FinalCoordinate_Z = Coordinate_Z;
Source.sendFeedback(()->{ return Text.translatable("info.success", entity.getName(), FinalCoordinate_X, FinalCoordinate_Y, FinalCoordinate_Z); },true);
Source.sendFeedback(Text.translatable("info.twd.rtp.success", entity.getName(), FinalCoordinate_X, FinalCoordinate_Y, FinalCoordinate_Z),true);
return 0;}
static int execute_command_origin(ServerCommandSource Source, @Nullable Long Radius, @Nullable Entity Player, Entity Origin){
return execute_command(Source, Radius, Player, Origin.getPos());}

View File

@@ -17,6 +17,6 @@ public class RandomTeleporter implements ModInitializer {
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.
CommandRegister.Register();
LOGGER.info("RandomTeleporter Loading!");
LOGGER.info("Hello Fabric world!");
}
}

View File

@@ -1,6 +1,6 @@
{
"modmenu.nameTranslation.randomteleporter": "RandomTeleporter",
"modmenu.descriptionTranslation.randomteleporter": "Added two commands for random teleportation",
"bilibili": "Bilibili",
"blog": "Blog"
"twd.bilibili": "Bilibili",
"twd.blog": "Blog"
}

View File

@@ -1,8 +1,9 @@
{
"modmenu.nameTranslation.randomteleporter": "随机传送",
"modmenu.descriptionTranslation.randomteleporter": "增加了两个用于随机传送的命令",
"info.success": "已将玩家%s传送到%d %d %d",
"error.not_player": "执行命令的不是玩家",
"bilibili": "TheWhiteDog9487的哔哩哔哩主页",
"blog": "TheWhiteDog9487的博客"
"info.twd.rtp.success": "已将玩家%s传送到%d %d %d",
"error.twd.rtp.not_player": "执行命令的不是玩家",
"warning.twd.rtp.retry": "重试次数过大,为避免死循环将在本次传送中取消距离保护",
"twd.bilibili": "哔哩哔哩主页",
"twd.blog": "TheWhiteDog9487的博客"
}

View File

@@ -27,9 +27,9 @@
}
],
"depends": {
"fabricloader": ">=0.15.11",
"minecraft": "1.21",
"java": ">=21",
"fabricloader": ">=0.15.7",
"minecraft": "~1.19.1",
"java": ">=17",
"fabric-api": "*"
},
"suggests": {
@@ -38,7 +38,7 @@
"custom": {
"modmenu": {
"links": {
"bilibili": "https://space.bilibili.com/401746666",
"blog": "www.thewhitedog9487.xyz"},
"twd.bilibili": "https://space.bilibili.com/401746666",
"twd.blog": "www.thewhitedog9487.xyz"},
"update_checker": true}}
}

View File

@@ -1,7 +1,7 @@
{
"required": false,
"package": "xyz.thewhitedog9487.mixin",
"compatibilityLevel": "JAVA_21",
"compatibilityLevel": "JAVA_17",
"mixins": [
],