本文整理汇总了Java中net.minecraft.command.ICommandSender.getEntityWorld方法的典型用法代码示例。如果您正苦于以下问题:Java ICommandSender.getEntityWorld方法的具体用法?Java ICommandSender.getEntityWorld怎么用?Java ICommandSender.getEntityWorld使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.command.ICommandSender
的用法示例。
在下文中一共展示了ICommandSender.getEntityWorld方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cast
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void cast(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
World world = sender.getEntityWorld();
BlockPos source = sender.getPosition();
for (BlockPos pos : BlockPos.getAllInBox(source.add(5, 5, 5), source.add(-5, -5, -5))) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileCandle && ((TileCandle) tile).isLit()) {
for (int i = 0; i < 5; i++) {
double x = pos.getX() + world.rand.nextFloat();
double y = pos.getY() + world.rand.nextFloat();
double z = pos.getZ() + world.rand.nextFloat();
world.spawnParticle(EnumParticleTypes.FLAME, x, y, z, 0, 0, 0);
}
((TileCandle) tile).unLitCandle();
PacketHandler.updateToNearbyPlayers(world, pos);
}
}
EnergyHandler.addEnergy((EntityPlayer) sender, 800);
}
示例2: cast
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void cast(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
World world = sender.getEntityWorld();
BlockPos source = sender.getPosition();
for (BlockPos pos : BlockPos.getAllInBox(source.add(5, 5, 5), source.add(-5, -5, -5))) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileCandle && !((TileCandle) tile).isLit()) {
for (int i = 0; i < 5; i++) {
double x = pos.getX() + world.rand.nextFloat();
double y = pos.getY() + world.rand.nextFloat();
double z = pos.getZ() + world.rand.nextFloat();
world.spawnParticle(EnumParticleTypes.FLAME, x, y, z, 0, 0, 0);
}
((TileCandle) tile).litCandle();
PacketHandler.updateToNearbyPlayers(world, pos);
}
}
EnergyHandler.addEnergy((EntityPlayer) sender, 800);
}
示例3: processCommand
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
BlockPos blockpos;
if (args.length == 0)
{
blockpos = getCommandSenderAsPlayer(sender).getPosition();
}
else
{
if (args.length != 3 || sender.getEntityWorld() == null)
{
throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]);
}
blockpos = parseBlockPos(sender, args, 0, true);
}
sender.getEntityWorld().setSpawnPoint(blockpos);
MinecraftServer.getServer().getConfigurationManager().sendPacketToAllPlayers(new S05PacketSpawnPosition(blockpos));
notifyOperators(sender, this, "commands.setworldspawn.success", new Object[] {Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
}
示例4: execute
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
World world = sender.getEntityWorld();
if (!world.isRemote && args.length > 0)
{
EntityPlayer player = this.getCommandSenderAsPlayer(sender);
EntityCurse curse = null;
EnumCurseType curseType = EnumCurseType.byName(args[0]);
switch(curseType)
{
case CREEPER: curse = new EntityCreeperCurse(world, player); break;
case GHAST: curse = new EntityGhastCurse(world, player); break;
case SKELETON: curse = new EntitySkeletonCurse(world, player); break;
case SLIME: curse = new EntitySlimeCurse(world, player); break;
case SPIDER: curse = new EntitySpiderCurse(world, player); break;
case ZOMBIE: curse = new EntityZombieCurse(world, player); break;
}
world.spawnEntity(curse);
}
}
示例5: execute
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
BlockPos blockpos;
if (args.length == 0)
{
blockpos = getCommandSenderAsPlayer(sender).getPosition();
}
else
{
if (args.length != 3 || sender.getEntityWorld() == null)
{
throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]);
}
blockpos = parseBlockPos(sender, args, 0, true);
}
sender.getEntityWorld().setSpawnPoint(blockpos);
server.getPlayerList().sendPacketToAllPlayers(new SPacketSpawnPosition(blockpos));
notifyCommandListener(sender, this, "commands.setworldspawn.success", new Object[] {Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
}
示例6: execGen
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
/** Generate world region. Very high-weight for cpu-calculation resources command
* @param vars Variables to parse arguments
* @param sender Who sends the command
*/
static void execGen(Variables vars, ICommandSender sender) {
int size = vars.get(new String[]{"size", "s", "length", "radius", "r"}, 16);
int startX = vars.get(new String[]{"startx", "sx"}, 0);
int startZ = vars.get(new String[]{"startz", "sz"}, 0);
boolean stop = vars.get(new String[]{"stop", "end", "finish"}, false);
boolean skip = vars.get(new String[]{"skip"}, false);
int progress = vars.get(new String[]{"progress"}, 0);
int step = Math.min(Math.max(1, vars.get(new String[]{"step", "delta"}, 32)), 4096);
String worldName = vars.get(new String[]{"world"});
UWorld world = worldName == null ? new UWorld(sender.getEntityWorld()) : UWorld.getWorld(worldName);
if (world == null) {
feedback(sender, "§4No matching world");
return;
}
feedback(sender, Evaluator.cmdGen(world, startX, startZ, step, size, stop, skip, progress));
}
示例7: execSave
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
/** Saves fragment from the world to schematic
* @param vars Variables to parse arguments
* @param sender Who sends the command
*/
static void execSave(Variables vars, ICommandSender sender) {
String name = vars.get(new String[]{"name"}, "unnamed");
UBlockPos where = new UBlockPos(0, 0, 0);
if (sender instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) sender;
where = new UBlockPos((int)player.posX, (int)player.posY, (int)player.posZ);
}
int posX = vars.get(new String[]{"posx", "px", "x"}, where.getX());
int posY = vars.get(new String[]{"posy", "py", "y"}, where.getY());
int posZ = vars.get(new String[]{"posz", "pz", "z"}, where.getZ());
int width = vars.get(new String[]{"width", "w"}, 64);
int height = vars.get(new String[]{"height", "h"}, 64);
int length = vars.get(new String[]{"length", "l"}, 64);
if (vars.get(new String[]{"wand"}, false) && sender instanceof EntityPlayer && wand.containsKey(sender)) {
UBlockPos posK = wand.get(sender).getKey();
UBlockPos posV = wand.get(sender).getValue();
posX = Math.min(posK.getX(), posV.getX());
posY = Math.min(posK.getY(), posV.getY());
posZ = Math.min(posK.getZ(), posV.getZ());
width = Math.max(posK.getX(), posV.getX()) - posX + 1;
height = Math.max(posK.getY(), posV.getY()) - posY + 1;
length = Math.max(posK.getZ(), posV.getZ()) - posZ + 1;
}
String worldName = vars.get(new String[]{"world"});
UWorld world = worldName == null ? new UWorld(sender.getEntityWorld()) : UWorld.getWorld(worldName);
if (world == null) {
feedback(sender, "§4No matching world");
return;
}
feedback(sender, Evaluator.cmdSave(world, name, posX, posY, posZ, width, height, length));
}
示例8: reload
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@HarshenCommand
public static void reload(MinecraftServer server, ICommandSender sender, String[] args)
{
BaseConfig.reloadAll();
for(EntityPlayer player : sender.getEntityWorld().playerEntities)
HandlerSyncConfig.syncConfigWithClient((EntityPlayerMP) player);
message(sender, "success");
}
示例9: execPaste
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
/** Paste something to the world
* @param vars Variables to parse arguments
* @param sender Who sends the command
*/
static void execPaste(Variables vars, ICommandSender sender) {
Random random = new Random();
String name = vars.get(new String[]{"name"}, "");
UBlockPos where = new UBlockPos(0, 0, 0);
if (sender instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) sender;
where = new UBlockPos((int)player.posX, (int)player.posY, (int)player.posZ);
}
int posX = vars.get(new String[]{"posx", "px", "x"}, where.getX());
int posY = vars.get(new String[]{"posy", "py", "y"}, where.getY());
int posZ = vars.get(new String[]{"posz", "pz", "z"}, where.getZ());
int rotateX = vars.get(new String[]{"rotatex", "rotx", "rx"}, 0);
int rotateY = vars.get(new String[]{"rotatey", "roty", "ry"}, random.nextInt() % 4);
int rotateZ = vars.get(new String[]{"rotatez", "rotz", "rz"}, 0);
boolean flipX = vars.get(new String[]{"flipx", "fx"}, random.nextBoolean());
boolean flipY = vars.get(new String[]{"flipy", "fy"}, false);
boolean flipZ = vars.get(new String[]{"flipz", "fz"}, random.nextBoolean());
boolean isVillage = vars.get(new String[]{"village", "town", "city"}, false);
boolean isInsecure = vars.get(new String[]{"insecure"}, false);
posY = vars.get(new String[]{"auto"}, false) ? 0 : posY;
if (vars.get(new String[]{"wand"}, false) && sender instanceof EntityPlayer && wand.containsKey(sender)) {
UBlockPos pos = wand.get(sender).getValue();
posX = pos.getX(); posY = pos.getY(); posZ = pos.getZ();
}
String worldName = vars.get(new String[]{"world"});
UWorld world = worldName == null ? new UWorld(sender.getEntityWorld()) : UWorld.getWorld(worldName);
if (world == null) {
feedback(sender, "No matching world");
return;
}
feedback(sender, Evaluator.cmdPaste(world, name, posX, posY, posZ, rotateX, rotateY, rotateZ, flipX, flipY, flipZ, isVillage, isInsecure));
}
示例10: execSave
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
/** Saves fragment from the world to schematic
* @param vars Variables to parse arguments
* @param sender Who sends the command
*/
static void execSave(Variables vars, ICommandSender sender) {
String name = vars.get(new String[]{"name"}, "unnamed");
int posX = vars.get(new String[]{"posx", "px", "x"}, sender.getPosition().getX());
int posY = vars.get(new String[]{"posy", "py", "y"}, sender.getPosition().getY());
int posZ = vars.get(new String[]{"posz", "pz", "z"}, sender.getPosition().getZ());
int width = vars.get(new String[]{"width", "w"}, 64);
int height = vars.get(new String[]{"height", "h"}, 64);
int length = vars.get(new String[]{"length", "l"}, 64);
if (vars.get(new String[]{"wand"}, false) && sender instanceof EntityPlayer && wand.containsKey(sender)) {
UBlockPos posK = wand.get(sender).getKey();
UBlockPos posV = wand.get(sender).getValue();
posX = Math.min(posK.getX(), posV.getX());
posY = Math.min(posK.getY(), posV.getY());
posZ = Math.min(posK.getZ(), posV.getZ());
width = Math.max(posK.getX(), posV.getX()) - posX + 1;
height = Math.max(posK.getY(), posV.getY()) - posY + 1;
length = Math.max(posK.getZ(), posV.getZ()) - posZ + 1;
}
String worldName = vars.get(new String[]{"world"});
UWorld world = worldName == null ? new UWorld(sender.getEntityWorld()) : UWorld.getWorld(worldName);
if (world == null) {
feedback(sender, "§4No matching world");
return;
}
feedback(sender, Evaluator.cmdSave(world, name, posX, posY, posZ, width, height, length));
}
示例11: execute
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
World world = sender.getEntityWorld();
if (!world.isRemote)
{
if (args.length == 0)
{
for (Map.Entry<Integer, String> kvp : VillagerRegistryHelper.getProfessionIdsAndNamesSortedById())
{
sender.sendMessage(new TextComponentString(kvp.getKey() + ": " + kvp.getValue()));
}
return;
}
if (args.length == 2 && args[0].equals("profession"))
{
VillagerProfession profession = VillagerRegistryHelper.getProfession(args[1]);
if (profession != null)
{
for (VillagerCareer career : new VTTVillagerProfession(profession).getCareers())
{
VTTVillagerCareer vttCareer = new VTTVillagerCareer(career);
sender.sendMessage(new TextComponentString(vttCareer.getId() + ": " + vttCareer.getName()));
sender.sendMessage(new TextComponentString(" " + vttCareer.getCareerLevels() + " levels"));
}
}
}
}
}
示例12: execPaste
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
/** Paste something to the world
* @param vars Variables to parse arguments
* @param sender Who sends the command
*/
static void execPaste(Variables vars, ICommandSender sender) {
Random random = new Random();
String name = vars.get(new String[]{"name"}, "");
int posX = vars.get(new String[]{"posx", "px", "x"}, sender.getPosition().getX());
int posY = vars.get(new String[]{"posy", "py", "y"}, sender.getPosition().getY());
int posZ = vars.get(new String[]{"posz", "pz", "z"}, sender.getPosition().getZ());
int rotateX = vars.get(new String[]{"rotatex", "rotx", "rx"}, 0);
int rotateY = vars.get(new String[]{"rotatey", "roty", "ry"}, random.nextInt() % 4);
int rotateZ = vars.get(new String[]{"rotatez", "rotz", "rz"}, 0);
boolean flipX = vars.get(new String[]{"flipx", "fx"}, random.nextBoolean());
boolean flipY = vars.get(new String[]{"flipy", "fy"}, false);
boolean flipZ = vars.get(new String[]{"flipz", "fz"}, random.nextBoolean());
boolean isVillage = vars.get(new String[]{"village", "town", "city"}, false);
boolean isInsecure = vars.get(new String[]{"insecure"}, false);
posY = vars.get(new String[]{"auto"}, false) ? 0 : posY;
if (vars.get(new String[]{"wand"}, false) && sender instanceof EntityPlayer && wand.containsKey(sender)) {
UBlockPos pos = wand.get(sender).getValue();
posX = pos.getX(); posY = pos.getY(); posZ = pos.getZ();
}
String worldName = vars.get(new String[]{"world"});
UWorld world = worldName == null ? new UWorld(sender.getEntityWorld()) : UWorld.getWorld(worldName);
if (world == null) {
feedback(sender, "No matching world");
return;
}
feedback(sender, Evaluator.cmdPaste(world, name, posX, posY, posZ, rotateX, rotateY, rotateZ, flipX, flipY, flipZ, isVillage, isInsecure));
}
示例13: execute
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args)
throws CommandException {
World world = sender.getEntityWorld();
if (!world.isRemote) {
if (args.length == 0) {
showUsage(sender);
return;
}
if (args[0].equalsIgnoreCase("start")) {
YouTubeConfiguration configuration = YouTubeConfiguration.getInstance();
String clientSecret = configuration.getClientSecret();
if (clientSecret == null || clientSecret.isEmpty()) {
showMessage("No client secret configurated", sender);
return;
}
service.start(configuration.getVideoId(), clientSecret, sender);
} else if (args[0].equalsIgnoreCase("stop")) {
service.stop(sender);
} else if (args[0].equalsIgnoreCase("logout")) {
service.stop(sender);
try {
Auth.clearCredentials();
} catch(IOException e) {
showMessage(e.getMessage(), sender);
}
} else {
if (args[0].equalsIgnoreCase("echoStart")) {
if (!service.isInitialized()) {
showMessage("Service is not initialized", sender);
showUsage(sender);
} else {
service.subscribe(this);
}
} else if (args[0].equalsIgnoreCase("echoStop")) {
service.unsubscribe(this);
} else {
showUsage(sender);
}
}
}
}