如果选定的传送坐标的下方一格是水或岩浆,自动放一个石头填上,让玩家传送过去后有一个可以站的平台,别直接掉下去了。
This commit is contained in:
TheWhiteDog9487 2024-02-02 15:38:04 +08:00
parent 133fb882ef
commit b9c7fb3088
2 changed files with 7 additions and 1 deletions

View File

@ -9,7 +9,7 @@ yarn_mappings=1.20.4+build.3
loader_version=0.15.6 loader_version=0.15.6
# Mod Properties # Mod Properties
mod_version=0.2.2 mod_version=0.2.3
maven_group=xyz.thewhitedog9487 maven_group=xyz.thewhitedog9487
archives_base_name=randomteleporter archives_base_name=randomteleporter

View File

@ -11,6 +11,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.SplittableRandom; import java.util.SplittableRandom;
@ -185,6 +186,11 @@ public class CommandRegister {
Blocks.VOID_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.CAVE_AIR == Source.getWorld().getBlockState(new BlockPos(Math.toIntExact(Coordinate_X), Coordinate_Y, Math.toIntExact(Coordinate_Z))).getBlock() Blocks.CAVE_AIR == Source.getWorld().getBlockState(new BlockPos(Math.toIntExact(Coordinate_X), Coordinate_Y, Math.toIntExact(Coordinate_Z))).getBlock()
;Coordinate_Y--){} ;Coordinate_Y--){}
if (Blocks.WATER == 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()){
Source.getWorld().setBlockState(new BlockPos(Math.toIntExact(Coordinate_X), Coordinate_Y, Math.toIntExact(Coordinate_Z)), Blocks.STONE.getDefaultState());}
// 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++;
Vec3d Coordinate = new Vec3d(Coordinate_X, Coordinate_Y, Coordinate_Z); Vec3d Coordinate = new Vec3d(Coordinate_X, Coordinate_Y, Coordinate_Z);
if (Radius == WorldBorder && Retry < 126 && Distance(entity.getPos(), Coordinate) < 1e5){ if (Radius == WorldBorder && Retry < 126 && Distance(entity.getPos(), Coordinate) < 1e5){