本文整理了Java中net.minecraft.world.World.getMinecraftServer()
方法的一些代码示例,展示了World.getMinecraftServer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。World.getMinecraftServer()
方法的具体详情如下:
包路径:net.minecraft.world.World
类名称:World
方法名:getMinecraftServer
暂无
代码示例来源:origin: SleepyTrousers/EnderIO
@Override
@Nullable
public MinecraftServer getMinecraftServer() {
return wrapped.getMinecraftServer();
}
代码示例来源:origin: PrinceOfAmber/Cyclic
public static void addChatMessage(World worldObj, ITextComponent textComponentTranslation) {
if (worldObj.getMinecraftServer() != null) {
worldObj.getMinecraftServer().sendMessage(textComponentTranslation);
}
}
代码示例来源:origin: SquidDev-CC/plethora
public CommandAPI(Entity entity) {
this.entity = entity;
this.server = entity.getEntityWorld().getMinecraftServer();
}
代码示例来源:origin: amadornes/MCMultiPart
@Override
public MinecraftServer getMinecraftServer() {
return getActualWorld().getMinecraftServer();
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
private UUID findUUID(String name) {
if (this.world == null || this.world.getMinecraftServer() == null)
return EntityPlayer.getOfflineUUID(name);
GameProfile profile = this.world.getMinecraftServer().getPlayerProfileCache().getGameProfileForUsername(name);
return profile == null ? EntityPlayer.getOfflineUUID(name) : profile.getId();
}
代码示例来源:origin: lawremi/CustomOreGen
@SubscribeEvent
public void onClientLogin(PlayerLoggedInEvent event)
{
World handlerWorld = event.player.world;
ServerState.checkIfServerChanged(handlerWorld.getMinecraftServer(),
handlerWorld.getWorldInfo());
}
代码示例来源:origin: lawremi/CustomOreGen
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
{
ServerState.checkIfServerChanged(world.getMinecraftServer(), world.getWorldInfo());
ServerState.onPopulateChunk(world, chunkX, chunkZ, random);
}
代码示例来源:origin: ldtteam/minecolonies
/**
* Add a player to the rankings.
*
* @param player String playername of the player to add.
* @param rank Rank desired starting rank.
* @param world the world the player is in.
* @return True if successful, otherwise false.
*/
public boolean addPlayer(@NotNull final String player, final Rank rank, final World world)
{
if (player.isEmpty())
{
return false;
}
final GameProfile gameprofile = world.getMinecraftServer().getPlayerProfileCache().getGameProfileForUsername(player);
//Check if the player already exists so that their rank isn't overridden
return gameprofile != null && ownerUUID != gameprofile.getId() && addPlayer(gameprofile, rank);
}
代码示例来源:origin: MCTCP/TerrainControl
@Override
public SpawnableObject getMojangStructurePart(String name)
{
ResourceLocation resourceLocation = new ResourceLocation(name);
TemplateManager mojangStructureParts = this.world.getSaveHandler().getStructureTemplateManager();
Template mojangStructurePart = mojangStructureParts.getTemplate(this.world.getMinecraftServer(), resourceLocation);
if (mojangStructurePart == null)
{
return null;
}
return new MojangStructurePart(name, mojangStructurePart);
}
代码示例来源:origin: SquidDev-CC/plethora
@Override
public void addStat(StatBase stat, int count) {
MinecraftServer server = world.getMinecraftServer();
if (server != null && getGameProfile() != PROFILE) {
EntityPlayerMP player = server.getPlayerList().getPlayerByUUID(getUniqueID());
if (player != null) player.addStat(stat, count);
}
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
type = EnumDragonEgg.values()[tag.getByte("Color")];
age = tag.getByte("Age");
String s;
if (tag.hasKey("OwnerUUID", 8)) {
s = tag.getString("OwnerUUID");
} else {
String s1 = tag.getString("Owner");
s = PreYggdrasilConverter.convertMobOwnerIfNeeded(this.world.getMinecraftServer(), s1);
}
if (!s.isEmpty()) {
ownerUUID = UUID.fromString(s);
}
}
代码示例来源:origin: TerraFirmaCraft/TerraFirmaCraft
private void placeBranch(TemplateManager manager, World world, BlockPos pos, String name)
{
ResourceLocation base = new ResourceLocation(TFCConstants.MOD_ID, name);
Template structureBase = manager.get(world.getMinecraftServer(), base);
if (structureBase == null)
{
TerraFirmaCraft.getLog().warn("Unable to find a template for " + base.toString());
return;
}
BlockPos size = structureBase.getSize();
pos = pos.add(-size.getX() / 2, 0, -size.getZ() / 2);
ITreeGenerator.addStructureToWorld(world, pos, structureBase, settings);
}
代码示例来源:origin: TerraFirmaCraft/TerraFirmaCraft
private void placeBranch(TemplateManager manager, World world, BlockPos pos, String name)
{
ResourceLocation base = new ResourceLocation(name);
Template structureBase = manager.get(world.getMinecraftServer(), base);
if (structureBase == null)
{
TerraFirmaCraft.getLog().warn("Unable to find a template for " + base.toString());
return;
}
BlockPos size = structureBase.getSize();
pos = pos.add(-size.getX() / 2, 0, -size.getZ() / 2);
ITreeGenerator.addStructureToWorld(world, pos, structureBase, settings);
}
代码示例来源:origin: JurassiCraftTeam/JurassiCraft2
@Override
protected void generateStructure(World world, Random random, BlockPos position) {
MinecraftServer server = world.getMinecraftServer();
TemplateManager templateManager = world.getSaveHandler().getStructureTemplateManager();
PlacementSettings settings = new PlacementSettings().setRotation(this.rotation).setMirror(this.mirror);
Template template = templateManager.getTemplate(server, STRUCTURE);
Map<BlockPos, String> dataBlocks = template.getDataBlocks(position, settings);
template.addBlocksToWorldChunk(world, position, settings);
dataBlocks.forEach((pos, type) -> {
if (type.equals("Chest")) {
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 3);
TileEntity tile = world.getTileEntity(pos.down());
if (tile instanceof TileEntityChest) {
((TileEntityChest) tile).setLootTable(LootTableList.CHESTS_VILLAGE_BLACKSMITH, random.nextLong()); //TODO Proper loottable
}
}
});
}
代码示例来源:origin: TerraFirmaCraft/TerraFirmaCraft
private int placeLayer(TemplateManager manager, World world, BlockPos pos, String name)
{
ResourceLocation base = new ResourceLocation(name);
Template structureBase = manager.get(world.getMinecraftServer(), base);
if (structureBase == null)
{
TerraFirmaCraft.getLog().warn("Unable to find a template for " + base.toString());
return -1;
}
BlockPos size = structureBase.getSize();
pos = pos.add(-size.getX() / 2, 0, -size.getZ() / 2);
ITreeGenerator.addStructureToWorld(world, pos, structureBase, settings);
return size.getY();
}
代码示例来源:origin: lawremi/CustomOreGen
@SubscribeEvent
public void onLoadWorld(WorldEvent.Load event)
{
World world = event.getWorld();
if (world instanceof WorldServer)
{
ServerState.checkIfServerChanged(world.getMinecraftServer(), world.getWorldInfo());
ServerState.getWorldConfig(world);
}
else if (event.getWorld() instanceof WorldClient && ClientState.hasWorldChanged(world))
{
ClientState.onWorldChanged(world);
}
}
代码示例来源:origin: Funwayguy/BetterQuesting
/**
* Ignores parameter on client side (uses own data instead)
*/
public void SyncTile(NBTTagCompound data)
{
if(!world.isRemote)
{
if(data != null) this.readFromNBT(data); // Note: The handler has already read out the "tile" subtag in advance
this.markDirty();
if(world.getMinecraftServer() != null) world.getMinecraftServer().getPlayerList().sendToAllNearExcept(null, pos.getX(), pos.getY(), pos.getZ(), 128, world.provider.getDimension(), getUpdatePacket());
} else
{
NBTTagCompound payload = new NBTTagCompound();
payload.setTag("tile", this.writeToNBT(new NBTTagCompound()));
PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.EDIT_STATION.GetLocation(), payload));
}
}
代码示例来源:origin: Vazkii/Quark
private void generateFossil(World world, Random random, BlockPos pos) {
MinecraftServer minecraftserver = world.getMinecraftServer();
Rotation[] arotation = Rotation.values();
Rotation rotation = arotation[random.nextInt(arotation.length)];
int i = random.nextInt(FOSSILS.length);
TemplateManager templatemanager = world.getSaveHandler().getStructureTemplateManager();
Template template = templatemanager.getTemplate(minecraftserver, FOSSILS[i]);
ChunkPos chunkpos = new ChunkPos(pos);
StructureBoundingBox structureboundingbox = new StructureBoundingBox(chunkpos.getXStart(), 0, chunkpos.getZStart(), chunkpos.getXEnd(), 256, chunkpos.getZEnd());
PlacementSettings placementsettings = (new PlacementSettings()).setRotation(rotation).setBoundingBox(structureboundingbox).setRandom(random);
BlockPos blockpos = template.transformedSize(rotation);
BlockPos blockpos1 = template.getZeroPositionWithTransform(pos, Mirror.NONE, rotation);
placementsettings.setIntegrity(1F);
template.addBlocksToWorld(world, blockpos1, placementsettings, 20);
}
代码示例来源:origin: McJtyMods/ModTutorials
public static void teleportToDimension(EntityPlayer player, int dimension, double x, double y, double z) {
int oldDimension = player.getEntityWorld().provider.getDimension();
EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player;
MinecraftServer server = player.getEntityWorld().getMinecraftServer();
WorldServer worldServer = server.getWorld(dimension);
player.addExperienceLevel(0);
if (worldServer == null || worldServer.getMinecraftServer() == null){ //Dimension doesn't exist
throw new IllegalArgumentException("Dimension: "+dimension+" doesn't exist!");
}
worldServer.getMinecraftServer().getPlayerList().transferPlayerToDimension(entityPlayerMP, dimension, new CustomTeleporter(worldServer, x, y, z));
player.setPositionAndUpdate(x, y, z);
if (oldDimension == 1) {
// For some reason teleporting out of the end does weird things.
player.setPositionAndUpdate(x, y, z);
worldServer.spawnEntity(player);
worldServer.updateEntityWithOptionalForce(player, false);
}
}
代码示例来源:origin: SquidDev-CC/plethora
@Override
public MethodResult call() throws Exception {
IContext<IModuleContainer> context = unbaked.bake();
// Create the chat event and post to chat
ITextComponent formatted = ForgeHooks.newChatWithLinks(message);
// Attempt to extract the server from the current world.
MinecraftServer server = null;
if (context.hasContext(ContextKeys.ORIGIN, IWorldLocation.class)) {
server = context.getContext(ContextKeys.ORIGIN, IWorldLocation.class).getWorld().getMinecraftServer();
}
// If that failed then just get the global server.
if (server == null) server = FMLCommonHandler.instance().getMinecraftServerInstance();
server.getPlayerList().sendMessage(formatted, false);
return MethodResult.empty();
}
});
内容来源于网络,如有侵权,请联系作者删除!