Package info.u_team.u_team_core.util
Klasse LevelUtil
java.lang.Object
info.u_team.u_team_core.util.LevelUtil
Some utility methods for level interaction.
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic <T extends net.minecraft.world.level.saveddata.SavedData>
TgetSaveData(net.minecraft.server.level.ServerLevel level, String name, BiFunction<net.minecraft.nbt.CompoundTag, net.minecraft.core.HolderLookup.Provider, T> load, Supplier<T> defaultData) Get a saved instance (own implementation) ofSavedData.static <T extends net.minecraft.world.level.saveddata.SavedData>
TgetSaveData(net.minecraft.server.level.ServerLevel level, BiFunction<net.minecraft.nbt.CompoundTag, net.minecraft.core.HolderLookup.Provider, T> load, String name, Function<String, T> defaultData) Get a saved instance (own implementation) ofSavedData.static net.minecraft.server.level.ServerLevelgetServerLevel(net.minecraft.server.MinecraftServer server, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> key) Get theServerLevelfrom theResourceKeystatic net.minecraft.server.level.ServerLevelgetServerLevel(net.minecraft.world.entity.Entity entity, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> key) Get theServerLevelfrom theResourceKeystatic net.minecraft.world.phys.HitResultrayTraceServerSide(net.minecraft.world.entity.Entity entity, double range) Raytrace from an entities look vector for collisions in range.static net.minecraft.world.phys.HitResultrayTraceServerSide(net.minecraft.world.entity.Entity entity, double range, net.minecraft.world.level.ClipContext.Block blockMode, net.minecraft.world.level.ClipContext.Fluid fluidMode) Raytrace from an entities look vector for collisions in range.static net.minecraft.world.entity.EntityteleportEntity(net.minecraft.world.entity.Entity entity, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> key, double x, double y, double z, float yaw, float pitch) Teleports any entity to a given location in a givenDimensionType.static net.minecraft.world.entity.EntityteleportEntity(net.minecraft.world.entity.Entity entity, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> key, net.minecraft.core.BlockPos pos) Teleports any entity to a given location in a givenServerLevel.static net.minecraft.world.entity.EntityteleportEntity(net.minecraft.world.entity.Entity entity, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> key, net.minecraft.world.phys.Vec3 pos) Teleports any entity to a given location in a givenServerLevel.static net.minecraft.world.entity.EntityteleportEntity(net.minecraft.world.entity.Entity entity, net.minecraft.server.level.ServerLevel level, double x, double y, double z, float yaw, float pitch) Teleports any entity to a given location in a givenServerLevel.static net.minecraft.world.entity.EntityteleportEntity(net.minecraft.world.entity.Entity entity, net.minecraft.server.level.ServerLevel level, double x, double y, double z, float yaw, float pitch, boolean detach) Teleports any entity to a given location in a givenServerLevel.static net.minecraft.world.entity.EntityteleportEntity(net.minecraft.world.entity.Entity entity, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos) Teleports any entity to a given location in a givenServerLevel.static net.minecraft.world.entity.EntityteleportEntity(net.minecraft.world.entity.Entity entity, net.minecraft.server.level.ServerLevel level, net.minecraft.world.phys.Vec3 pos) Teleports any entity to a given location in a givenServerLevel.
-
Konstruktordetails
-
LevelUtil
public LevelUtil()
-
-
Methodendetails
-
rayTraceServerSide
public static net.minecraft.world.phys.HitResult rayTraceServerSide(net.minecraft.world.entity.Entity entity, double range) Raytrace from an entities look vector for collisions in range. Use default block modeClipContext.Block.OUTLINEand fluid modeClipContext.Fluid.NONE.- Parameter:
entity- Entity from where we get the look vectorrange- Range in blocks- Gibt zurück:
- Raytrace result with information about the trace
-
rayTraceServerSide
public static net.minecraft.world.phys.HitResult rayTraceServerSide(net.minecraft.world.entity.Entity entity, double range, net.minecraft.world.level.ClipContext.Block blockMode, net.minecraft.world.level.ClipContext.Fluid fluidMode) Raytrace from an entities look vector for collisions in range.- Parameter:
entity- Entity from where we get the look vectorrange- Range in blocksblockMode- Mode for block collisionsfluidMode- Mode for fluid collisions- Gibt zurück:
- Raytrace result with information about the trace
-
getSaveData
public static <T extends net.minecraft.world.level.saveddata.SavedData> T getSaveData(net.minecraft.server.level.ServerLevel level, BiFunction<net.minecraft.nbt.CompoundTag, net.minecraft.core.HolderLookup.Provider, T> load, String name, Function<String, T> defaultData) Get a saved instance (own implementation) ofSavedData. If it does not exist, a new one is created.- Typparameter:
T- Custom level save data class- Parameter:
level- Server levelname- Name of this datadefaultData- Function for creating an instance and for the default instance- Gibt zurück:
- An instance of
with the loaded data or default data.
-
getSaveData
public static <T extends net.minecraft.world.level.saveddata.SavedData> T getSaveData(net.minecraft.server.level.ServerLevel level, String name, BiFunction<net.minecraft.nbt.CompoundTag, net.minecraft.core.HolderLookup.Provider, T> load, Supplier<T> defaultData) Get a saved instance (own implementation) ofSavedData. If it does not exist, a new one is created.- Typparameter:
T- Custom level save data class- Parameter:
level- Server levelname- Name of this datadefaultData- Supplier for creating an instance and for the default instance- Gibt zurück:
- An instance of
with the loaded data or default data.
-
getServerLevel
public static net.minecraft.server.level.ServerLevel getServerLevel(net.minecraft.world.entity.Entity entity, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> key) Get theServerLevelfrom theResourceKey- Parameter:
entity- An entity used to get the server instance withEntity.getServer()key- The dimension key- Gibt zurück:
- The server level for the given key
-
getServerLevel
public static net.minecraft.server.level.ServerLevel getServerLevel(net.minecraft.server.MinecraftServer server, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> key) Get theServerLevelfrom theResourceKey- Parameter:
server- The server instancekey- The dimension key- Gibt zurück:
- The server level for the given key
-
teleportEntity
public static net.minecraft.world.entity.Entity teleportEntity(net.minecraft.world.entity.Entity entity, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> key, net.minecraft.core.BlockPos pos) Teleports any entity to a given location in a givenServerLevel. Don't change the yaw and pitch of the entity.- Parameter:
entity- The entity to teleportkey- The dimension key where the entity should be teleported. Can be the same as the current dimension key or a different onepos- The position the entity should be teleported to- Gibt zurück:
- The teleported entity
-
teleportEntity
public static net.minecraft.world.entity.Entity teleportEntity(net.minecraft.world.entity.Entity entity, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> key, net.minecraft.world.phys.Vec3 pos) Teleports any entity to a given location in a givenServerLevel. Don't change the yaw and pitch of the entity.- Parameter:
entity- The entity to teleportkey- The dimension key where the entity should be teleported. Can be the same as the current dimension key or a different onepos- The position the entity should be teleported to- Gibt zurück:
- The teleported entity
-
teleportEntity
public static net.minecraft.world.entity.Entity teleportEntity(net.minecraft.world.entity.Entity entity, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos) Teleports any entity to a given location in a givenServerLevel. Don't change the yaw and pitch of the entity.- Parameter:
entity- The entity to teleportlevel- The server level where the entity should be teleported. Can be the same as the current level or a different onepos- The position the entity should be teleported to- Gibt zurück:
- The teleported entity
-
teleportEntity
public static net.minecraft.world.entity.Entity teleportEntity(net.minecraft.world.entity.Entity entity, net.minecraft.server.level.ServerLevel level, net.minecraft.world.phys.Vec3 pos) Teleports any entity to a given location in a givenServerLevel. Don't change the yaw and pitch of the entity.- Parameter:
entity- The entity to teleportlevel- The server level where the entity should be teleported. Can be the same as the current level or a different onepos- The position the entity should be teleported to- Gibt zurück:
- The teleported entity
-
teleportEntity
public static net.minecraft.world.entity.Entity teleportEntity(net.minecraft.world.entity.Entity entity, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> key, double x, double y, double z, float yaw, float pitch) Teleports any entity to a given location in a givenDimensionType.- Parameter:
entity- The entity to teleportkey- The dimension key where the entity should be teleported. Can be the same as the current dimension key or a different onex- X-Coordinatey- Y-Coordinatez- Z-Coordinateyaw- Yawpitch- Pitch- Gibt zurück:
- The teleported entity
-
teleportEntity
public static net.minecraft.world.entity.Entity teleportEntity(net.minecraft.world.entity.Entity entity, net.minecraft.server.level.ServerLevel level, double x, double y, double z, float yaw, float pitch) Teleports any entity to a given location in a givenServerLevel.- Parameter:
entity- The entity to teleportlevel- The server level where the entity should be teleported. Can be the same as the current level or a different onex- X-Coordinatey- Y-Coordinatez- Z-Coordinateyaw- Yawpitch- Pitch- Gibt zurück:
- The teleported entity
-
teleportEntity
public static net.minecraft.world.entity.Entity teleportEntity(net.minecraft.world.entity.Entity entity, net.minecraft.server.level.ServerLevel level, double x, double y, double z, float yaw, float pitch, boolean detach) Teleports any entity to a given location in a givenServerLevel.- Parameter:
entity- The entity to teleportlevel- The server level where the entity should be teleported. Can be the same as the current level or a different onex- X-Coordinatey- Y-Coordinatez- Z-Coordinateyaw- Yawpitch- Pitchdetach- Detach the entity- Gibt zurück:
- The teleported entity
-