mirror of
https://github.com/TheWhiteDog9487/RandomTeleporter.git
synced 2024-11-21 20:17:05 +08:00
0.3.2
修改了一下传送落地之后玻璃的放置规则。 - 以前只要脚下是水或岩浆就无条件替换,在极小概率之下可能出现一些麻烦,所以我给改掉了。 - 现在是落地就准备替换,但是只会替换水、岩浆和空气,其他所有都会保留不变。 当然最重要的是适配Minecraft 1.21.2 另外针对开发者侧,Gradle语法从Groovy换到了Kotlin,看起来舒服多了。
This commit is contained in:
parent
6d3af41b34
commit
e7c99c2364
@ -44,7 +44,9 @@ dependencies {
|
|||||||
// Uncomment the following line to enable the deprecated Fabric API modules.
|
// Uncomment the following line to enable the deprecated Fabric API modules.
|
||||||
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
|
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
|
||||||
// "modImplementation"("net.fabricmc.fabric-api:fabric-api-deprecated:${project.extra["fabric_version"]}")
|
// "modImplementation"("net.fabricmc.fabric-api:fabric-api-deprecated:${project.extra["fabric_version"]}")
|
||||||
testImplementation("com.terraformersmc:modmenu:${project.extra["modmenu_version"]}")
|
|
||||||
|
// ↓ 开发测试用
|
||||||
|
modRuntimeOnly("com.terraformersmc:modmenu:${project.extra["modmenu_version"]}")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.processResources {
|
tasks.processResources {
|
||||||
@ -72,11 +74,16 @@ java {
|
|||||||
tasks.jar {
|
tasks.jar {
|
||||||
from("LICENSE") {
|
from("LICENSE") {
|
||||||
rename { "${it}_${project.base.archivesName.get()}" } }
|
rename { "${it}_${project.base.archivesName.get()}" } }
|
||||||
|
|
||||||
// https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Jar.html#org.gradle.api.tasks.bundling.Jar:archiveFileName
|
|
||||||
archiveFileName = "${project.base.archivesName.get()}-${project.version} mc${project.extra["minecraft_version"]}.jar"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.remapJar{
|
||||||
|
// https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Jar.html#org.gradle.api.tasks.bundling.Jar:archiveFileName
|
||||||
|
// 用这个属性设置jar包的文件名格式
|
||||||
|
// 别用上面那个Jar任务的配置,会被remapJar覆盖掉
|
||||||
|
archiveFileName = "${project.base.archivesName.get()}-${project.version} mc${project.extra["minecraft_version"]}.jar"}
|
||||||
|
tasks.remapSourcesJar{
|
||||||
|
archiveFileName = "${project.base.archivesName.get()}-${project.version} mc${project.extra["minecraft_version"]}-sources.jar"}
|
||||||
|
|
||||||
// configure the maven publication
|
// configure the maven publication
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
|
@ -4,20 +4,24 @@ org.gradle.parallel=true
|
|||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/develop
|
# check these on https://fabricmc.net/develop
|
||||||
minecraft_version=1.21.1
|
minecraft_version=1.21.2
|
||||||
yarn_mappings=1.21.1+build.3
|
yarn_mappings=1.21.2+build.1
|
||||||
loader_version=0.15.11
|
loader_version=0.16.7
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=0.3.1
|
mod_version=0.3.2
|
||||||
maven_group=xyz.thewhitedog9487
|
maven_group=xyz.thewhitedog9487
|
||||||
archives_base_name=randomteleporter
|
archives_base_name=randomteleporter
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
fabric_version=0.102.0+1.21.1
|
fabric_version=0.106.1+1.21.2
|
||||||
|
|
||||||
loom_libraries_base=https://bmclapi2.bangbang93.com/maven/
|
# https://modrinth.com/mod/modmenu/versions
|
||||||
loom_resources_base=https://bmclapi2.bangbang93.com/assets/
|
# https://maven.terraformersmc.com/releases/com/terraformersmc/modmenu
|
||||||
loom_version_manifests=https://bmclapi2.bangbang93.com/mc/game/version_manifest.json
|
modmenu_version=12.0.0-beta.1
|
||||||
loom_experimental_versions=https://maven.fabricmc.net/net/minecraft/experimental_versions.json
|
|
||||||
|
# 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/
|
@ -113,11 +113,11 @@ public class CommandRegister {
|
|||||||
.then(argument("被传送玩家名(PlayerID)", EntityArgumentType.entity())
|
.then(argument("被传送玩家名(PlayerID)", EntityArgumentType.entity())
|
||||||
.then(argument("OriginEntity(随机中心,实体)",EntityArgumentType.entity())
|
.then(argument("OriginEntity(随机中心,实体)",EntityArgumentType.entity())
|
||||||
.requires(source -> source.hasPermissionLevel(PermissionLevel))
|
.requires(source -> source.hasPermissionLevel(PermissionLevel))
|
||||||
.executes(context -> execute_command_origin(
|
.executes(context -> execute_command(
|
||||||
context.getSource(),
|
context.getSource(),
|
||||||
LongArgumentType.getLong(context, "Radius(半径)"),
|
LongArgumentType.getLong(context, "Radius(半径)"),
|
||||||
EntityArgumentType.getEntity(context,"被传送玩家名(PlayerID)"),
|
EntityArgumentType.getEntity(context,"被传送玩家名(PlayerID)"),
|
||||||
EntityArgumentType.getEntity(context,"OriginEntity(随机中心,实体)")))))));});
|
EntityArgumentType.getEntity(context,"OriginEntity(随机中心,实体)").getPos()))))));});
|
||||||
|
|
||||||
// /rtp <Radius(半径)> <被传送玩家名(PlayerID)> <OriginPos(随机中心,坐标)>
|
// /rtp <Radius(半径)> <被传送玩家名(PlayerID)> <OriginPos(随机中心,坐标)>
|
||||||
CommandRegistrationCallback.EVENT
|
CommandRegistrationCallback.EVENT
|
||||||
@ -141,11 +141,11 @@ public class CommandRegister {
|
|||||||
.then(argument("Radius(半径)", LongArgumentType.longArg())
|
.then(argument("Radius(半径)", LongArgumentType.longArg())
|
||||||
.then(argument("OriginEntity(随机中心,实体)",EntityArgumentType.entity())
|
.then(argument("OriginEntity(随机中心,实体)",EntityArgumentType.entity())
|
||||||
.requires(source -> source.hasPermissionLevel(PermissionLevel))
|
.requires(source -> source.hasPermissionLevel(PermissionLevel))
|
||||||
.executes(context -> execute_command_origin(
|
.executes(context -> execute_command(
|
||||||
context.getSource(),
|
context.getSource(),
|
||||||
LongArgumentType.getLong(context, "Radius(半径)"),
|
LongArgumentType.getLong(context, "Radius(半径)"),
|
||||||
EntityArgumentType.getEntity(context,"被传送玩家名(PlayerID)"),
|
EntityArgumentType.getEntity(context,"被传送玩家名(PlayerID)"),
|
||||||
EntityArgumentType.getEntity(context,"OriginEntity(随机中心,实体)")))))));});
|
EntityArgumentType.getEntity(context,"OriginEntity(随机中心,实体)").getPos()))))));});
|
||||||
|
|
||||||
// /rtp <被传送玩家名(PlayerID)> <Radius(半径)> <OriginPos(随机中心,坐标)>
|
// /rtp <被传送玩家名(PlayerID)> <Radius(半径)> <OriginPos(随机中心,坐标)>
|
||||||
CommandRegistrationCallback.EVENT
|
CommandRegistrationCallback.EVENT
|
||||||
@ -179,25 +179,30 @@ public class CommandRegister {
|
|||||||
Coordinate_X = new SplittableRandom().nextLong(Math.round(Origin.getX() - Radius), Math.round(Origin.getX() + Radius));
|
Coordinate_X = new SplittableRandom().nextLong(Math.round(Origin.getX() - Radius), Math.round(Origin.getX() + Radius));
|
||||||
Coordinate_Z = new SplittableRandom().nextLong(Math.round(Origin.getZ() - Radius), Math.round(Origin.getZ() + Radius));}
|
Coordinate_Z = new SplittableRandom().nextLong(Math.round(Origin.getZ() - Radius), Math.round(Origin.getZ() + Radius));}
|
||||||
int Coordinate_Y = 320;
|
int Coordinate_Y = 320;
|
||||||
for (;
|
for (var CurrentBlock = Source.getWorld().getBlockState(new BlockPos(Math.toIntExact(Coordinate_X), Coordinate_Y, Math.toIntExact(Coordinate_Z))).getBlock();
|
||||||
Blocks.AIR == Source.getWorld().getBlockState(new BlockPos(Math.toIntExact(Coordinate_X), Coordinate_Y, Math.toIntExact(Coordinate_Z))).getBlock() ||
|
// 从世界顶层往下找,直到遇到一个非空气方块
|
||||||
Blocks.VOID_AIR == Source.getWorld().getBlockState(new BlockPos(Math.toIntExact(Coordinate_X), Coordinate_Y, Math.toIntExact(Coordinate_Z))).getBlock() ||
|
Blocks.AIR == CurrentBlock ||
|
||||||
Blocks.CAVE_AIR == Source.getWorld().getBlockState(new BlockPos(Math.toIntExact(Coordinate_X), Coordinate_Y, Math.toIntExact(Coordinate_Z))).getBlock()
|
Blocks.VOID_AIR == CurrentBlock ||
|
||||||
;Coordinate_Y--){}
|
Blocks.CAVE_AIR == CurrentBlock
|
||||||
if (Blocks.WATER == Source.getWorld().getBlockState(new BlockPos(Math.toIntExact(Coordinate_X), Coordinate_Y, Math.toIntExact(Coordinate_Z))).getBlock() ||
|
;CurrentBlock = Source.getWorld().getBlockState(new BlockPos(Math.toIntExact(Coordinate_X), Coordinate_Y, Math.toIntExact(Coordinate_Z))).getBlock()){
|
||||||
Blocks.LAVA == Source.getWorld().getBlockState(new BlockPos(Math.toIntExact(Coordinate_X), Coordinate_Y, Math.toIntExact(Coordinate_Z))).getBlock()){
|
Coordinate_Y--;}
|
||||||
for (int x = -1; x <= 1; x++) {
|
for (int x = -1; x <= 1; x++) {
|
||||||
for (int z = -1; z <= 1; z++) {
|
for (int z = -1; z <= 1; z++) {
|
||||||
Source.getWorld().setBlockState(new BlockPos(Math.toIntExact(Coordinate_X - x), Coordinate_Y, Math.toIntExact(Coordinate_Z - z)), Blocks.GLASS.getDefaultState());}}}
|
// 如果传送到的位置周围一圈是空气、水或岩浆,将其替换为玻璃
|
||||||
|
var BlockPos = new BlockPos(Math.toIntExact(Coordinate_X - x), Coordinate_Y, Math.toIntExact(Coordinate_Z - z));
|
||||||
|
var CurrentBlock = Source.getWorld().getBlockState(BlockPos).getBlock();
|
||||||
|
if ( CurrentBlock == Blocks.AIR ||
|
||||||
|
CurrentBlock == Blocks.VOID_AIR ||
|
||||||
|
CurrentBlock == Blocks.CAVE_AIR ||
|
||||||
|
CurrentBlock == Blocks.WATER ||
|
||||||
|
CurrentBlock == Blocks.LAVA ){
|
||||||
|
// 只替换空气、水和岩浆,其余保留
|
||||||
|
Source.getWorld().setBlockState(BlockPos, Blocks.GLASS.getDefaultState());}}}
|
||||||
// if ( String.valueOf(entity.getWorld().getBiome(new BlockPos(Math.toIntExact(Coordinate_X), Coordinate_Y, Math.toIntExact(Coordinate_Z))).getKey()).equals("minecraft:the_void") ) {
|
// 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++;}
|
||||||
Coordinate_Y++;
|
Coordinate_Y++;
|
||||||
entity.teleport(Source.getWorld(),Coordinate_X + 0.5, Coordinate_Y, Coordinate_Z + 0.5, new HashSet<>(), entity.getYaw(), entity.getPitch());
|
// ↑ 高一层,人别站在土里了
|
||||||
final long FinalCoordinate_X = Coordinate_X;
|
entity.teleport(Source.getWorld(),Coordinate_X + 0.5, Coordinate_Y, Coordinate_Z + 0.5, new HashSet<>(), entity.getYaw(), entity.getPitch(), false);
|
||||||
final int FinalCoordinate_Y = Coordinate_Y;
|
Source.sendFeedback(()->{ return Text.translatable("info.success", entity.getName(), Coordinate_Z, Coordinate_Z, Coordinate_Z); },true);
|
||||||
final long FinalCoordinate_Z = Coordinate_Z;
|
|
||||||
Source.sendFeedback(()->{ return Text.translatable("info.success", entity.getName(), FinalCoordinate_X, FinalCoordinate_Y, FinalCoordinate_Z); },true);
|
|
||||||
return 0;}
|
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());}
|
|
||||||
}
|
}
|
@ -28,7 +28,7 @@
|
|||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.15.11",
|
"fabricloader": ">=0.15.11",
|
||||||
"minecraft": "1.21.1",
|
"minecraft": "1.21.2",
|
||||||
"java": ">=21",
|
"java": ">=21",
|
||||||
"fabric-api": "*"
|
"fabric-api": "*"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user