本文整理匯總了Java中net.minecraft.server.MinecraftServer.worldServerForDimension方法的典型用法代碼示例。如果您正苦於以下問題:Java MinecraftServer.worldServerForDimension方法的具體用法?Java MinecraftServer.worldServerForDimension怎麽用?Java MinecraftServer.worldServerForDimension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.server.MinecraftServer
的用法示例。
在下文中一共展示了MinecraftServer.worldServerForDimension方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (args.length <= 0) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Use 'all', 'passive', 'hostile' or name of the mob followed by optional dimension id"));
InControl.logger.error("Use 'all', 'passive', 'hostile', 'entity' or name of the mob followed by optional dimension id");
return;
}
int dimension = (sender instanceof EntityPlayer) ? sender.getEntityWorld().provider.getDimension() : 0;
if (args.length > 1) {
dimension = Integer.parseInt(args[1]);
}
String arg0 = args[0].toLowerCase();
boolean all = "all".equals(arg0);
boolean passive = "passive".equals(arg0);
boolean hostile = "hostile".equals(arg0);
boolean entity = "entity".equals(arg0);
WorldServer worldServer = server.worldServerForDimension(dimension);
List<Entity> entities = worldServer.getEntities(Entity.class, input -> {
if (all) {
return !(input instanceof EntityPlayer);
} else if (passive) {
return input instanceof IAnimals && !(input instanceof IMob);
} else if (hostile) {
return input instanceof IMob;
} else if (entity) {
return !(input instanceof IAnimals) && !(input instanceof EntityPlayer);
} else {
String id = EntityTools.findEntityIdByClass(input.getClass());
return arg0.equals(id);
}
});
for (Entity e : entities) {
worldServer.removeEntity(e);
}
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.YELLOW + "Removed " + entities.size() + " entities!"));
}
示例2: getByIdentifier
import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
@Override
public TileEntity getByIdentifier(MinecraftServer server) {
World world = server.worldServerForDimension(dimId);
if (world == null) return null;
return world.getTileEntity(pos);
}
示例3: isLoaded
import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
@Override
public boolean isLoaded(MinecraftServer server) {
World world = server.worldServerForDimension(dimId);
if (world == null) return false;
return world.getTileEntity(pos) != null;
}
示例4: travelToDimension
import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
/**
* Teleports the entity to another dimension. Params: Dimension number to teleport to
*/
public void travelToDimension(int dimensionId)
{
if (!this.worldObj.isRemote && !this.isDead)
{
this.worldObj.theProfiler.startSection("changeDimension");
MinecraftServer minecraftserver = MinecraftServer.getServer();
int i = this.dimension;
WorldServer worldserver = minecraftserver.worldServerForDimension(i);
WorldServer worldserver1 = minecraftserver.worldServerForDimension(dimensionId);
this.dimension = dimensionId;
if (i == 1 && dimensionId == 1)
{
worldserver1 = minecraftserver.worldServerForDimension(0);
this.dimension = 0;
}
this.worldObj.removeEntity(this);
this.isDead = false;
this.worldObj.theProfiler.startSection("reposition");
minecraftserver.getConfigurationManager().transferEntityToWorld(this, i, worldserver, worldserver1);
this.worldObj.theProfiler.endStartSection("reloading");
Entity entity = EntityList.createEntityByName(EntityList.getEntityString(this), worldserver1);
if (entity != null)
{
entity.copyDataFromOld(this);
if (i == 1 && dimensionId == 1)
{
BlockPos blockpos = this.worldObj.getTopSolidOrLiquidBlock(worldserver1.getSpawnPoint());
entity.moveToBlockPosAndAngles(blockpos, entity.rotationYaw, entity.rotationPitch);
}
worldserver1.spawnEntityInWorld(entity);
}
this.isDead = true;
this.worldObj.theProfiler.endSection();
worldserver.resetUpdateEntityTick();
worldserver1.resetUpdateEntityTick();
this.worldObj.theProfiler.endSection();
}
}
示例5: execute
import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
World world = (World)(sender instanceof EntityPlayer ? ((EntityPlayer)sender).world : server.worldServerForDimension(0));
sender.addChatMessage(new TextComponentTranslation("commands.seed.success", new Object[] {Long.valueOf(world.getSeed())}));
}
示例6: execute
import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
World world = (World)(sender instanceof EntityPlayer ? ((EntityPlayer)sender).worldObj : server.worldServerForDimension(0));
sender.addChatMessage(new TextComponentTranslation("commands.seed.success", new Object[] {Long.valueOf(world.getSeed())}));
}