本文整理汇总了Java中net.minecraft.world.World.getMinecraftServer方法的典型用法代码示例。如果您正苦于以下问题:Java World.getMinecraftServer方法的具体用法?Java World.getMinecraftServer怎么用?Java World.getMinecraftServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.world.World
的用法示例。
在下文中一共展示了World.getMinecraftServer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyItemEntityDataToEntity
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* Applies the data in the EntityTag tag of the given ItemStack to the given Entity.
*/
public static void applyItemEntityDataToEntity(World entityWorld, @Nullable EntityPlayer player, ItemStack stack, @Nullable Entity targetEntity)
{
MinecraftServer minecraftserver = entityWorld.getMinecraftServer();
if (minecraftserver != null && targetEntity != null)
{
NBTTagCompound nbttagcompound = stack.getTagCompound();
if (nbttagcompound != null && nbttagcompound.hasKey("EntityTag", 10))
{
if (!entityWorld.isRemote && targetEntity.ignoreItemEntityData() && (player == null || !minecraftserver.getPlayerList().canSendCommands(player.getGameProfile())))
{
return;
}
NBTTagCompound nbttagcompound1 = targetEntity.writeToNBT(new NBTTagCompound());
UUID uuid = targetEntity.getUniqueID();
nbttagcompound1.merge(nbttagcompound.getCompoundTag("EntityTag"));
targetEntity.setUniqueId(uuid);
targetEntity.readFromNBT(nbttagcompound1);
}
}
}
示例2: getPlayer
import net.minecraft.world.World; //导入方法依赖的package包/类
@Nullable
@Override
public EntityPlayer getPlayer() {
if (playerId == null) {
return null;
}
World world = DimensionManager.getWorld(0);
MinecraftServer server = world.getMinecraftServer();
return server.getPlayerList().getPlayerByUUID(playerId);
}
示例3: generate
import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean generate(World worldIn, Random rand, BlockPos position)
{
Random random = worldIn.getChunkFromBlockCoords(position).getRandomWithSeed(987234911L);
MinecraftServer minecraftserver = worldIn.getMinecraftServer();
Rotation[] arotation = Rotation.values();
Rotation rotation = arotation[random.nextInt(arotation.length)];
int i = random.nextInt(FOSSILS.length);
TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager();
Template template = templatemanager.getTemplate(minecraftserver, FOSSILS[i]);
Template template1 = templatemanager.getTemplate(minecraftserver, FOSSILS_COAL[i]);
ChunkPos chunkpos = new ChunkPos(position);
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);
int j = random.nextInt(16 - blockpos.getX());
int k = random.nextInt(16 - blockpos.getZ());
int l = 256;
for (int i1 = 0; i1 < blockpos.getX(); ++i1)
{
for (int j1 = 0; j1 < blockpos.getX(); ++j1)
{
l = Math.min(l, worldIn.getHeight(position.getX() + i1 + j, position.getZ() + j1 + k));
}
}
int k1 = Math.max(l - 15 - random.nextInt(10), 10);
BlockPos blockpos1 = template.getZeroPositionWithTransform(position.add(j, k1, k), Mirror.NONE, rotation);
placementsettings.setIntegrity(0.9F);
template.addBlocksToWorld(worldIn, blockpos1, placementsettings, 20);
placementsettings.setIntegrity(0.1F);
template1.addBlocksToWorld(worldIn, blockpos1, placementsettings, 20);
return true;
}
示例4: generate
import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean generate(World worldIn, Random rand, BlockPos position)
{
Random random = worldIn.getChunkFromChunkCoords(position.getX(), position.getZ()).getRandomWithSeed(987234911L);
MinecraftServer minecraftserver = worldIn.getMinecraftServer();
Rotation[] arotation = Rotation.values();
Rotation rotation = arotation[random.nextInt(arotation.length)];
int i = random.nextInt(FOSSILS.length);
TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager();
Template template = templatemanager.getTemplate(minecraftserver, FOSSILS[i]);
Template template1 = templatemanager.getTemplate(minecraftserver, FOSSILS_COAL[i]);
ChunkPos chunkpos = new ChunkPos(position);
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);
int j = random.nextInt(16 - blockpos.getX());
int k = random.nextInt(16 - blockpos.getZ());
int l = 256;
for (int i1 = 0; i1 < blockpos.getX(); ++i1)
{
for (int j1 = 0; j1 < blockpos.getX(); ++j1)
{
l = Math.min(l, worldIn.getHeightmapHeight(position.getX() + i1 + j, position.getZ() + j1 + k));
}
}
int k1 = Math.max(l - 15 - random.nextInt(10), 10);
BlockPos blockpos1 = template.getZeroPositionWithTransform(position.add(j, k1, k), Mirror.NONE, rotation);
placementsettings.setIntegrity(0.9F);
template.addBlocksToWorld(worldIn, blockpos1, placementsettings, 4);
placementsettings.setIntegrity(0.1F);
template1.addBlocksToWorld(worldIn, blockpos1, placementsettings, 4);
return true;
}
示例5: addComponentParts
import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
{
if (!this.offsetToAverageGroundLevel(worldIn, structureBoundingBoxIn, -1))
{
return false;
}
else
{
StructureBoundingBox structureboundingbox = this.getBoundingBox();
BlockPos blockpos = new BlockPos(structureboundingbox.minX, structureboundingbox.minY, structureboundingbox.minZ);
Rotation[] arotation = Rotation.values();
MinecraftServer minecraftserver = worldIn.getMinecraftServer();
TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager();
PlacementSettings placementsettings = (new PlacementSettings()).setRotation(arotation[randomIn.nextInt(arotation.length)]).setReplacedBlock(Blocks.STRUCTURE_VOID).setBoundingBox(structureboundingbox);
Template template = templatemanager.getTemplate(minecraftserver, IGLOO_TOP_ID);
template.addBlocksToWorldChunk(worldIn, blockpos, placementsettings);
if (randomIn.nextDouble() < 0.5D)
{
Template template1 = templatemanager.getTemplate(minecraftserver, IGLOO_MIDDLE_ID);
Template template2 = templatemanager.getTemplate(minecraftserver, IGLOO_BOTTOM_ID);
int i = randomIn.nextInt(8) + 4;
for (int j = 0; j < i; ++j)
{
BlockPos blockpos1 = template.calculateConnectedPos(placementsettings, new BlockPos(3, -1 - j * 3, 5), placementsettings, new BlockPos(1, 2, 1));
template1.addBlocksToWorldChunk(worldIn, blockpos.add(blockpos1), placementsettings);
}
BlockPos blockpos4 = blockpos.add(template.calculateConnectedPos(placementsettings, new BlockPos(3, -1 - i * 3, 5), placementsettings, new BlockPos(3, 5, 7)));
template2.addBlocksToWorldChunk(worldIn, blockpos4, placementsettings);
Map<BlockPos, String> map = template2.getDataBlocks(blockpos4, placementsettings);
for (Entry<BlockPos, String> entry : map.entrySet())
{
if ("chest".equals(entry.getValue()))
{
BlockPos blockpos2 = (BlockPos)entry.getKey();
worldIn.setBlockState(blockpos2, Blocks.AIR.getDefaultState(), 3);
TileEntity tileentity = worldIn.getTileEntity(blockpos2.down());
if (tileentity instanceof TileEntityChest)
{
((TileEntityChest)tileentity).setLootTable(LootTableList.CHESTS_IGLOO_CHEST, randomIn.nextLong());
}
}
}
}
else
{
BlockPos blockpos3 = Template.transformedBlockPos(placementsettings, new BlockPos(3, 0, 5));
worldIn.setBlockState(blockpos.add(blockpos3), Blocks.SNOW.getDefaultState(), 3);
}
return true;
}
}
示例6: setTileEntityNBT
import net.minecraft.world.World; //导入方法依赖的package包/类
public static boolean setTileEntityNBT(World worldIn, @Nullable EntityPlayer player, BlockPos pos, ItemStack stackIn)
{
MinecraftServer minecraftserver = worldIn.getMinecraftServer();
if (minecraftserver == null)
{
return false;
}
else
{
NBTTagCompound nbttagcompound = stackIn.getSubCompound("BlockEntityTag");
if (nbttagcompound != null)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity != null)
{
if (!worldIn.isRemote && tileentity.onlyOpsCanSetNbt() && (player == null || !player.canUseCommandBlock()))
{
return false;
}
NBTTagCompound nbttagcompound1 = tileentity.writeToNBT(new NBTTagCompound());
NBTTagCompound nbttagcompound2 = nbttagcompound1.copy();
nbttagcompound1.merge(nbttagcompound);
nbttagcompound1.setInteger("x", pos.getX());
nbttagcompound1.setInteger("y", pos.getY());
nbttagcompound1.setInteger("z", pos.getZ());
if (!nbttagcompound1.equals(nbttagcompound2))
{
tileentity.readFromNBT(nbttagcompound1);
tileentity.markDirty();
return true;
}
}
}
return false;
}
}
示例7: addComponentParts
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
* Mineshafts at the end, it adds Fences...
*/
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
{
if (!this.offsetToAverageGroundLevel(worldIn, structureBoundingBoxIn, -1))
{
return false;
}
else
{
StructureBoundingBox structureboundingbox = this.getBoundingBox();
BlockPos blockpos = new BlockPos(structureboundingbox.minX, structureboundingbox.minY, structureboundingbox.minZ);
Rotation[] arotation = Rotation.values();
MinecraftServer minecraftserver = worldIn.getMinecraftServer();
TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager();
PlacementSettings placementsettings = (new PlacementSettings()).setRotation(arotation[randomIn.nextInt(arotation.length)]).setReplacedBlock(Blocks.STRUCTURE_VOID).setBoundingBox(structureboundingbox);
Template template = templatemanager.getTemplate(minecraftserver, IGLOO_TOP_ID);
template.addBlocksToWorldChunk(worldIn, blockpos, placementsettings);
if (randomIn.nextDouble() < 0.5D)
{
Template template1 = templatemanager.getTemplate(minecraftserver, IGLOO_MIDDLE_ID);
Template template2 = templatemanager.getTemplate(minecraftserver, IGLOO_BOTTOM_ID);
int i = randomIn.nextInt(8) + 4;
for (int j = 0; j < i; ++j)
{
BlockPos blockpos1 = template.calculateConnectedPos(placementsettings, new BlockPos(3, -1 - j * 3, 5), placementsettings, new BlockPos(1, 2, 1));
template1.addBlocksToWorldChunk(worldIn, blockpos.add(blockpos1), placementsettings);
}
BlockPos blockpos4 = blockpos.add(template.calculateConnectedPos(placementsettings, new BlockPos(3, -1 - i * 3, 5), placementsettings, new BlockPos(3, 5, 7)));
template2.addBlocksToWorldChunk(worldIn, blockpos4, placementsettings);
Map<BlockPos, String> map = template2.getDataBlocks(blockpos4, placementsettings);
for (Entry<BlockPos, String> entry : map.entrySet())
{
if ("chest".equals(entry.getValue()))
{
BlockPos blockpos2 = (BlockPos)entry.getKey();
worldIn.setBlockState(blockpos2, Blocks.AIR.getDefaultState(), 3);
TileEntity tileentity = worldIn.getTileEntity(blockpos2.down());
if (tileentity instanceof TileEntityChest)
{
((TileEntityChest)tileentity).setLootTable(LootTableList.CHESTS_IGLOO_CHEST, randomIn.nextLong());
}
}
}
}
else
{
BlockPos blockpos3 = Template.transformedBlockPos(placementsettings, new BlockPos(3, 0, 5));
worldIn.setBlockState(blockpos.add(blockpos3), Blocks.SNOW.getDefaultState(), 3);
}
return true;
}
}
示例8: setTileEntityNBT
import net.minecraft.world.World; //导入方法依赖的package包/类
public static boolean setTileEntityNBT(World worldIn, @Nullable EntityPlayer player, BlockPos pos, ItemStack stackIn)
{
MinecraftServer minecraftserver = worldIn.getMinecraftServer();
if (minecraftserver == null)
{
return false;
}
else
{
if (stackIn.hasTagCompound() && stackIn.getTagCompound().hasKey("BlockEntityTag", 10))
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity != null)
{
if (!worldIn.isRemote && tileentity.onlyOpsCanSetNbt() && (player == null || !player.canUseCommandBlock()))
{
return false;
}
NBTTagCompound nbttagcompound = tileentity.writeToNBT(new NBTTagCompound());
NBTTagCompound nbttagcompound1 = nbttagcompound.copy();
NBTTagCompound nbttagcompound2 = (NBTTagCompound)stackIn.getTagCompound().getTag("BlockEntityTag");
nbttagcompound.merge(nbttagcompound2);
nbttagcompound.setInteger("x", pos.getX());
nbttagcompound.setInteger("y", pos.getY());
nbttagcompound.setInteger("z", pos.getZ());
if (!nbttagcompound.equals(nbttagcompound1))
{
tileentity.readFromNBT(nbttagcompound);
tileentity.markDirty();
return true;
}
}
}
return false;
}
}