mirror of
https://github.com/TheWhiteDog9487/RandomTeleporter.git
synced 2024-11-22 12:37:05 +08:00
Compare commits
3 Commits
3d23f397f7
...
e7c99c2364
Author | SHA1 | Date | |
---|---|---|---|
e7c99c2364 | |||
6d3af41b34 | |||
da8e07baea |
91
build.gradle
91
build.gradle
@ -1,91 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'fabric-loom' version '1.7-SNAPSHOT'
|
|
||||||
id 'maven-publish'
|
|
||||||
}
|
|
||||||
|
|
||||||
version = project.mod_version + " mc$project.minecraft_version"
|
|
||||||
group = project.maven_group
|
|
||||||
|
|
||||||
base {
|
|
||||||
archivesName = project.archives_base_name
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
// Add repositories to retrieve artifacts from in here.
|
|
||||||
// You should only use this when depending on other mods because
|
|
||||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
|
||||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
|
||||||
// for more information about repositories.
|
|
||||||
}
|
|
||||||
|
|
||||||
loom {
|
|
||||||
splitEnvironmentSourceSets()
|
|
||||||
|
|
||||||
mods {
|
|
||||||
"randomteleporter" {
|
|
||||||
sourceSet sourceSets.main
|
|
||||||
sourceSet sourceSets.client
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
// To change the versions see the gradle.properties file
|
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
|
||||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
|
||||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
|
||||||
|
|
||||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
|
|
||||||
}
|
|
||||||
|
|
||||||
processResources {
|
|
||||||
inputs.property "version", project.version
|
|
||||||
|
|
||||||
filesMatching("fabric.mod.json") {
|
|
||||||
expand "version": project.version
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
|
||||||
it.options.release = 21
|
|
||||||
}
|
|
||||||
|
|
||||||
java {
|
|
||||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
|
||||||
// if it is present.
|
|
||||||
// If you remove this line, sources will not be generated.
|
|
||||||
withSourcesJar()
|
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_21
|
|
||||||
targetCompatibility = JavaVersion.VERSION_21
|
|
||||||
}
|
|
||||||
|
|
||||||
jar {
|
|
||||||
from("LICENSE") {
|
|
||||||
rename { "${it}_${project.base.archivesName.get()}"}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// configure the maven publication
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
mavenJava(MavenPublication) {
|
|
||||||
from components.java
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
|
||||||
repositories {
|
|
||||||
// Add repositories to publish to here.
|
|
||||||
// Notice: This block does NOT have the same function as the block in the top level.
|
|
||||||
// The repositories here will be used for publishing your artifact, not for
|
|
||||||
// retrieving dependencies.
|
|
||||||
}
|
|
||||||
}
|
|
102
build.gradle.kts
Normal file
102
build.gradle.kts
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
plugins {
|
||||||
|
id("fabric-loom") version "1.8-SNAPSHOT"
|
||||||
|
id("maven-publish")
|
||||||
|
}
|
||||||
|
|
||||||
|
version = "${project.extra["mod_version"]}"
|
||||||
|
group = project.extra["maven_group"] as String
|
||||||
|
|
||||||
|
base {
|
||||||
|
archivesName.set(project.extra["archives_base_name"] as String)
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
// Add repositories to retrieve artifacts from in here.
|
||||||
|
// You should only use this when depending on other mods because
|
||||||
|
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||||
|
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||||
|
// for more information about repositories.
|
||||||
|
maven {
|
||||||
|
name = "Terraformers"
|
||||||
|
url = uri("https://maven.terraformersmc.com/") }
|
||||||
|
}
|
||||||
|
|
||||||
|
loom {
|
||||||
|
splitEnvironmentSourceSets()
|
||||||
|
|
||||||
|
mods {
|
||||||
|
create("randomteleporter") {
|
||||||
|
sourceSet(sourceSets["main"])
|
||||||
|
sourceSet(sourceSets["client"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// To change the versions see the gradle.properties file
|
||||||
|
minecraft("com.mojang:minecraft:${project.extra["minecraft_version"]}")
|
||||||
|
mappings("net.fabricmc:yarn:${project.extra["yarn_mappings"]}:v2")
|
||||||
|
modImplementation("net.fabricmc:fabric-loader:${project.extra["loader_version"]}")
|
||||||
|
|
||||||
|
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||||
|
modImplementation("net.fabricmc.fabric-api:fabric-api:${project.extra["fabric_version"]}")
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
// "modImplementation"("net.fabricmc.fabric-api:fabric-api-deprecated:${project.extra["fabric_version"]}")
|
||||||
|
|
||||||
|
// ↓ 开发测试用
|
||||||
|
modRuntimeOnly("com.terraformersmc:modmenu:${project.extra["modmenu_version"]}")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.processResources {
|
||||||
|
inputs.property("version", project.version)
|
||||||
|
|
||||||
|
filesMatching("fabric.mod.json") {
|
||||||
|
expand("version" to project.version)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<JavaCompile> {
|
||||||
|
options.release.set(21)
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||||
|
// if it is present.
|
||||||
|
// If you remove this line, sources will not be generated.
|
||||||
|
withSourcesJar()
|
||||||
|
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_21
|
||||||
|
targetCompatibility = JavaVersion.VERSION_21
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.jar {
|
||||||
|
from("LICENSE") {
|
||||||
|
rename { "${it}_${project.base.archivesName.get()}" } }
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("mavenJava") {
|
||||||
|
from(components["java"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||||
|
repositories {
|
||||||
|
// Add repositories to publish to here.
|
||||||
|
// Notice: This block does NOT have the same function as the block in the top level.
|
||||||
|
// The repositories here will be used for publishing your artifact, not for
|
||||||
|
// retrieving dependencies.
|
||||||
|
}
|
||||||
|
}
|
@ -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
|
minecraft_version=1.21.2
|
||||||
yarn_mappings=1.21+build.9
|
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
|
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/
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https://services.gradle.org/distributions/gradle-8.9-bin.zip
|
distributionUrl=https://services.gradle.org/distributions/gradle-8.10-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
pluginManagement {
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
name = 'Fabric'
|
|
||||||
url = 'https://maven.aliyun.com/repository/gradle-plugin'
|
|
||||||
url = 'https://maven.fabricmc.net/'
|
|
||||||
}
|
|
||||||
mavenCentral()
|
|
||||||
gradlePluginPortal()
|
|
||||||
}
|
|
||||||
}
|
|
9
settings.gradle.kts
Normal file
9
settings.gradle.kts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "Fabric"
|
||||||
|
url = uri("https://maven.fabricmc.net/") }
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
@ -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",
|
"minecraft": "1.21.2",
|
||||||
"java": ">=21",
|
"java": ">=21",
|
||||||
"fabric-api": "*"
|
"fabric-api": "*"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user