Java 类net.minecraft.world.GameType 实例源码
项目:creativezone
文件:CreativeZoneMod.java
@SubscribeEvent
public void onWorldTick(TickEvent.WorldTickEvent e) {
if (!e.world.isRemote && e.phase == TickEvent.Phase.START && e.world.provider.getDimension() == 0) {
long now = Instant.now().getEpochSecond();
if (now - lastCheck > checkInterval) {
BlockPos spawn = e.world.getSpawnPoint();
for (int i = 0; i < e.world.playerEntities.size(); i++)
{
EntityPlayer p = e.world.playerEntities.get(i);
// If the user is inside the zone radius, force them back to creative
if (p.getDistance(spawn.getX(), p.posY, spawn.getZ()) < zoneRadius) {
p.setGameType(GameType.CREATIVE);
} else {
// Otherwise, the user is outside the radius and we need to force
// them back to survival (assuming they're not on the whitelist)
if (!whitelist.contains(p.getName())) {
p.setGameType(GameType.SURVIVAL);
}
}
}
lastCheck = now;
}
}
}
项目:Zombe-Modpack
文件:PlayerControllerMP.java
/**
* Attacks an entity
*/
public void attackEntity(EntityPlayer playerIn, Entity targetEntity)
{
//-ZMod-Ghost-fix
if (playerIn == targetEntity) return;
//-ZMod-?
if (!ZHandle.handle("checkReachUse", targetEntity, true)) return;
//------------------------------------------------------------
this.syncCurrentPlayItem();
this.connection.sendPacket(new CPacketUseEntity(targetEntity));
if (this.currentGameType != GameType.SPECTATOR)
{
playerIn.attackTargetEntityWithCurrentItem(targetEntity);
playerIn.resetCooldown();
}
}
项目:CustomWorldGen
文件:EntityPlayerMP.java
/**
* Sets the player's game mode and sends it to them.
*/
public void setGameType(GameType gameType)
{
this.interactionManager.setGameType(gameType);
this.connection.sendPacket(new SPacketChangeGameState(3, (float)gameType.getID()));
if (gameType == GameType.SPECTATOR)
{
this.dismountRidingEntity();
}
else
{
this.setSpectatingEntity(this);
}
this.sendPlayerAbilities();
this.markPotionsDirty();
}
项目:Backmemed
文件:SPacketJoinGame.java
/**
* Reads the raw packet data from the data stream.
*/
public void readPacketData(PacketBuffer buf) throws IOException
{
this.playerId = buf.readInt();
int i = buf.readUnsignedByte();
this.hardcoreMode = (i & 8) == 8;
i = i & -9;
this.gameType = GameType.getByID(i);
this.dimension = buf.readInt();
this.difficulty = EnumDifficulty.getDifficultyEnum(buf.readUnsignedByte());
this.maxPlayers = buf.readUnsignedByte();
this.worldType = WorldType.parseWorldType(buf.readStringFromBuffer(16));
if (this.worldType == null)
{
this.worldType = WorldType.DEFAULT;
}
this.reducedDebugInfo = buf.readBoolean();
}
项目:Backmemed
文件:WorldClient.java
public void doVoidFogParticles(int posX, int posY, int posZ)
{
int i = 32;
Random random = new Random();
ItemStack itemstack = this.mc.player.getHeldItemMainhand();
if (itemstack == null || Block.getBlockFromItem(itemstack.getItem()) != Blocks.BARRIER)
{
itemstack = this.mc.player.getHeldItemOffhand();
}
boolean flag = this.mc.playerController.getCurrentGameType() == GameType.CREATIVE && !itemstack.func_190926_b() && itemstack.getItem() == Item.getItemFromBlock(Blocks.BARRIER);
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int j = 0; j < 667; ++j)
{
this.showBarrierParticles(posX, posY, posZ, 16, random, flag, blockpos$mutableblockpos);
this.showBarrierParticles(posX, posY, posZ, 32, random, flag, blockpos$mutableblockpos);
}
}
项目:CustomWorldGen
文件:EntityPlayerMP.java
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound compound)
{
super.readEntityFromNBT(compound);
if (compound.hasKey("playerGameType", 99))
{
if (this.getServer().getForceGamemode())
{
this.interactionManager.setGameType(this.getServer().getGameType());
}
else
{
this.interactionManager.setGameType(GameType.getByID(compound.getInteger("playerGameType")));
}
}
}
项目:UniversalRemote
文件:EntityPlayerMPProxy.java
@Override
public void setGameType(GameType gameType) {
if (m_realPlayer == null) {
super.setGameType(gameType);
} else {
syncToRealPlayer();
m_realPlayer.setGameType(gameType);
syncPublicFieldsFromReal();
}
}
项目:UniversalRemote
文件:EntityPlayerProxy.java
@Override
public void setGameType(GameType gameType) {
if (m_realPlayer == null) {
super.setGameType(gameType);
} else {
m_realPlayer.setGameType(gameType);
}
}
项目:UniversalRemote
文件:HookedIntegratedPlayerList.java
@SuppressWarnings("unchecked")
public HookedIntegratedPlayerList(IntegratedPlayerList oldList) throws IllegalAccessException, NoSuchFieldException, SecurityException {
super(oldList.getServerInstance());
InjectionHandler.copyAllFieldsFromEx(this, oldList, IntegratedPlayerList.class);
mcServer = InjectionHandler.readFieldOfType(PlayerList.class, this, MinecraftServer.class);
gameType = InjectionHandler.readFieldOfType(PlayerList.class, this, GameType.class);
playerEntityList = InjectionHandler.readFieldOfType(PlayerList.class, this, List.class);
uuidToPlayerMap = InjectionHandler.readFieldOfType(PlayerList.class, this, Map.class);
}
项目:CustomWorldGen
文件:TeleportToPlayer.java
public TeleportToPlayer(Collection<NetworkPlayerInfo> p_i45493_1_)
{
this.items = Lists.<ISpectatorMenuObject>newArrayList();
for (NetworkPlayerInfo networkplayerinfo : PROFILE_ORDER.sortedCopy(p_i45493_1_))
{
if (networkplayerinfo.getGameType() != GameType.SPECTATOR)
{
this.items.add(new PlayerMenuObject(networkplayerinfo.getGameProfile()));
}
}
}
项目:Zombe-Modpack
文件:EntityPlayerMP.java
/**
* Returns true if the player is in spectator mode.
*/
public boolean isSpectator()
{
//-ZMod-Fly-noclip----------------------------------------------------
if (ZHandle.handle("isNoclip", this, false)) ZWrapper.setNoclip(this, true);
//--------------------------------------------------------------------
return this.interactionManager.getGameType() == GameType.SPECTATOR;
}
项目:Zombe-Modpack
文件:EntityPlayerMP.java
/**
* Attacks for the player the targeted entity with the currently equipped item. The equipped item has hitEntity
* called on it. Args: targetEntity
*/
public void attackTargetEntityWithCurrentItem(Entity targetEntity)
{
if (this.interactionManager.getGameType() == GameType.SPECTATOR)
{
this.setSpectatingEntity(targetEntity);
}
else
{
super.attackTargetEntityWithCurrentItem(targetEntity);
}
}
项目:Zombe-Modpack
文件:PlayerControllerMP.java
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, EnumHand stack)
{
if (this.currentGameType == GameType.SPECTATOR)
{
return EnumActionResult.PASS;
}
else
{
this.syncCurrentPlayItem();
this.connection.sendPacket(new CPacketPlayerTryUseItem(stack));
ItemStack itemstack = player.getHeldItem(stack);
if (player.getCooldownTracker().hasCooldown(itemstack.getItem()))
{
return EnumActionResult.PASS;
}
else
{
int i = itemstack.func_190916_E();
ActionResult<ItemStack> actionresult = itemstack.useItemRightClick(worldIn, player, stack);
ItemStack itemstack1 = actionresult.getResult();
if (itemstack1 != itemstack || itemstack1.func_190916_E() != i)
{
player.setHeldItem(stack, itemstack1);
}
return actionresult.getType();
}
}
}
项目:Zombe-Modpack
文件:PlayerControllerMP.java
/**
* Handles right clicking an entity from the entities side, sends a packet to the server.
*/
public EnumActionResult interactWithEntity(EntityPlayer player, Entity target, RayTraceResult raytrace, EnumHand heldItem)
{
this.syncCurrentPlayItem();
Vec3d vec3d = new Vec3d(raytrace.hitVec.xCoord - target.posX, raytrace.hitVec.yCoord - target.posY, raytrace.hitVec.zCoord - target.posZ);
this.connection.sendPacket(new CPacketUseEntity(target, heldItem, vec3d));
return this.currentGameType == GameType.SPECTATOR ? EnumActionResult.PASS : target.applyPlayerInteraction(player, vec3d, heldItem);
}
项目:CustomWorldGen
文件:WorldClient.java
public void doVoidFogParticles(int posX, int posY, int posZ)
{
int i = 32;
Random random = new Random();
ItemStack itemstack = this.mc.thePlayer.getHeldItemMainhand();
boolean flag = this.mc.playerController.getCurrentGameType() == GameType.CREATIVE && itemstack != null && Block.getBlockFromItem(itemstack.getItem()) == Blocks.BARRIER;
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int j = 0; j < 667; ++j)
{
this.showBarrierParticles(posX, posY, posZ, 16, random, flag, blockpos$mutableblockpos);
this.showBarrierParticles(posX, posY, posZ, 32, random, flag, blockpos$mutableblockpos);
}
}
项目:Backmemed
文件:EntityPlayerMP.java
public EntityPlayerMP(MinecraftServer server, WorldServer worldIn, GameProfile profile, PlayerInteractionManager interactionManagerIn)
{
super(worldIn, profile);
interactionManagerIn.thisPlayerMP = this;
this.interactionManager = interactionManagerIn;
BlockPos blockpos = worldIn.getSpawnPoint();
if (worldIn.provider.func_191066_m() && worldIn.getWorldInfo().getGameType() != GameType.ADVENTURE)
{
int i = Math.max(0, server.getSpawnRadius(worldIn));
int j = MathHelper.floor(worldIn.getWorldBorder().getClosestDistance((double)blockpos.getX(), (double)blockpos.getZ()));
if (j < i)
{
i = j;
}
if (j <= 1)
{
i = 1;
}
blockpos = worldIn.getTopSolidOrLiquidBlock(blockpos.add(this.rand.nextInt(i * 2 + 1) - i, 0, this.rand.nextInt(i * 2 + 1) - i));
}
this.mcServer = server;
this.statsFile = server.getPlayerList().getPlayerStatsFile(this);
this.stepHeight = 0.0F;
this.moveToBlockPosAndAngles(blockpos, 0.0F, 0.0F);
while (!worldIn.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty() && this.posY < 255.0D)
{
this.setPosition(this.posX, this.posY + 1.0D, this.posZ);
}
}
项目:Backmemed
文件:EntityPlayerMP.java
/**
* Attacks for the player the targeted entity with the currently equipped item. The equipped item has hitEntity
* called on it. Args: targetEntity
*/
public void attackTargetEntityWithCurrentItem(Entity targetEntity)
{
if (this.interactionManager.getGameType() == GameType.SPECTATOR)
{
this.setSpectatingEntity(targetEntity);
}
else
{
super.attackTargetEntityWithCurrentItem(targetEntity);
}
}
项目:CustomWorldGen
文件:IntegratedServer.java
/**
* On dedicated does nothing. On integrated, sets commandsAllowedForAll, gameType and allows external connections.
*/
public String shareToLAN(GameType type, boolean allowCheats)
{
try
{
int i = -1;
try
{
i = HttpUtil.getSuitableLanPort();
}
catch (IOException var5)
{
;
}
if (i <= 0)
{
i = 25564;
}
this.getNetworkSystem().addLanEndpoint((InetAddress)null, i);
LOGGER.info("Started on {}", new Object[] {Integer.valueOf(i)});
this.isPublic = true;
this.lanServerPing = new ThreadLanServerPing(this.getMOTD(), i + "");
this.lanServerPing.start();
this.getPlayerList().setGameType(type);
this.getPlayerList().setCommandsAllowedForAll(allowCheats);
this.mc.thePlayer.setPermissionLevel(allowCheats ? 4 : 0);
return i + "";
}
catch (IOException var6)
{
return null;
}
}
项目:CustomWorldGen
文件:SPacketJoinGame.java
public SPacketJoinGame(int playerIdIn, GameType gameTypeIn, boolean hardcoreModeIn, int dimensionIn, EnumDifficulty difficultyIn, int maxPlayersIn, WorldType worldTypeIn, boolean reducedDebugInfoIn)
{
this.playerId = playerIdIn;
this.dimension = dimensionIn;
this.difficulty = difficultyIn;
this.gameType = gameTypeIn;
this.maxPlayers = maxPlayersIn;
this.hardcoreMode = hardcoreModeIn;
this.worldType = worldTypeIn;
this.reducedDebugInfo = reducedDebugInfoIn;
}
项目:CustomWorldGen
文件:PlayerControllerMP.java
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, ItemStack stack, EnumHand hand)
{
if (this.currentGameType == GameType.SPECTATOR)
{
return EnumActionResult.PASS;
}
else
{
this.syncCurrentPlayItem();
this.connection.sendPacket(new CPacketPlayerTryUseItem(hand));
if (player.getCooldownTracker().hasCooldown(stack.getItem()))
{
return EnumActionResult.PASS;
}
else
{
if (net.minecraftforge.common.ForgeHooks.onItemRightClick(player, hand, stack)) return net.minecraft.util.EnumActionResult.PASS;
int i = stack.stackSize;
ActionResult<ItemStack> actionresult = stack.useItemRightClick(worldIn, player, hand);
ItemStack itemstack = (ItemStack)actionresult.getResult();
if (itemstack != stack || itemstack.stackSize != i)
{
player.setHeldItem(hand, itemstack);
if (itemstack.stackSize <= 0)
{
player.setHeldItem(hand, (ItemStack)null);
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, itemstack, hand);
}
}
return actionresult.getType();
}
}
}
项目:Backmemed
文件:SPacketRespawn.java
/**
* Reads the raw packet data from the data stream.
*/
public void readPacketData(PacketBuffer buf) throws IOException
{
this.dimensionID = buf.readInt();
this.difficulty = EnumDifficulty.getDifficultyEnum(buf.readUnsignedByte());
this.gameType = GameType.getByID(buf.readUnsignedByte());
this.worldType = WorldType.parseWorldType(buf.readStringFromBuffer(16));
if (this.worldType == null)
{
this.worldType = WorldType.DEFAULT;
}
}
项目:Backmemed
文件:SPacketJoinGame.java
public SPacketJoinGame(int playerIdIn, GameType gameTypeIn, boolean hardcoreModeIn, int dimensionIn, EnumDifficulty difficultyIn, int maxPlayersIn, WorldType worldTypeIn, boolean reducedDebugInfoIn)
{
this.playerId = playerIdIn;
this.dimension = dimensionIn;
this.difficulty = difficultyIn;
this.gameType = gameTypeIn;
this.maxPlayers = maxPlayersIn;
this.hardcoreMode = hardcoreModeIn;
this.worldType = worldTypeIn;
this.reducedDebugInfo = reducedDebugInfoIn;
}
项目:CustomWorldGen
文件:SPacketRespawn.java
public SPacketRespawn(int dimensionIdIn, EnumDifficulty difficultyIn, WorldType worldTypeIn, GameType gameModeIn)
{
this.dimensionID = dimensionIdIn;
this.difficulty = difficultyIn;
this.gameType = gameModeIn;
this.worldType = worldTypeIn;
}
项目:CustomWorldGen
文件:CommandPublishLocalServer.java
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
String s = server.shareToLAN(GameType.SURVIVAL, false);
if (s != null)
{
notifyCommandListener(sender, this, "commands.publish.started", new Object[] {s});
}
else
{
notifyCommandListener(sender, this, "commands.publish.failed", new Object[0]);
}
}
项目:CustomWorldGen
文件:PlayerControllerMP.java
/**
* Handles right clicking an entity, sends a packet to the server.
*/
public EnumActionResult interactWithEntity(EntityPlayer player, Entity target, @Nullable ItemStack heldItem, EnumHand hand)
{
this.syncCurrentPlayItem();
this.connection.sendPacket(new CPacketUseEntity(target, hand));
return this.currentGameType == GameType.SPECTATOR ? EnumActionResult.PASS : player.interact(target, heldItem, hand);
}
项目:Backmemed
文件:PlayerControllerMP.java
/**
* Handles right clicking an entity, sends a packet to the server.
*/
public EnumActionResult interactWithEntity(EntityPlayer player, Entity target, EnumHand heldItem)
{
this.syncCurrentPlayItem();
this.connection.sendPacket(new CPacketUseEntity(target, heldItem));
return this.currentGameType == GameType.SPECTATOR ? EnumActionResult.PASS : player.func_190775_a(target, heldItem);
}
项目:Backmemed
文件:PlayerControllerMP.java
/**
* Handles right clicking an entity from the entities side, sends a packet to the server.
*/
public EnumActionResult interactWithEntity(EntityPlayer player, Entity target, RayTraceResult raytrace, EnumHand heldItem)
{
this.syncCurrentPlayItem();
Vec3d vec3d = new Vec3d(raytrace.hitVec.xCoord - target.posX, raytrace.hitVec.yCoord - target.posY, raytrace.hitVec.zCoord - target.posZ);
this.connection.sendPacket(new CPacketUseEntity(target, heldItem, vec3d));
return this.currentGameType == GameType.SPECTATOR ? EnumActionResult.PASS : target.applyPlayerInteraction(player, vec3d, heldItem);
}
项目:Backmemed
文件:TeleportToPlayer.java
public TeleportToPlayer(Collection<NetworkPlayerInfo> p_i45493_1_)
{
this.items = Lists.<ISpectatorMenuObject>newArrayList();
for (NetworkPlayerInfo networkplayerinfo : PROFILE_ORDER.sortedCopy(p_i45493_1_))
{
if (networkplayerinfo.getGameType() != GameType.SPECTATOR)
{
this.items.add(new PlayerMenuObject(networkplayerinfo.getGameProfile()));
}
}
}
项目:Backmemed
文件:IntegratedServer.java
/**
* On dedicated does nothing. On integrated, sets commandsAllowedForAll, gameType and allows external connections.
*/
public String shareToLAN(GameType type, boolean allowCheats)
{
try
{
int i = -1;
try
{
i = HttpUtil.getSuitableLanPort();
}
catch (IOException var5)
{
;
}
if (i <= 0)
{
i = 25564;
}
this.getNetworkSystem().addLanEndpoint((InetAddress)null, i);
LOGGER.info("Started on {}", new Object[] {Integer.valueOf(i)});
this.isPublic = true;
this.lanServerPing = new ThreadLanServerPing(this.getMOTD(), i + "");
this.lanServerPing.start();
this.getPlayerList().setGameType(type);
this.getPlayerList().setCommandsAllowedForAll(allowCheats);
this.mc.player.setPermissionLevel(allowCheats ? 4 : 0);
return i + "";
}
catch (IOException var6)
{
return null;
}
}
项目:CustomWorldGen
文件:NetHandlerPlayServer.java
/**
* Processes the client status updates: respawn attempt from player, opening statistics or achievements, or
* acquiring 'open inventory' achievement
*/
public void processClientStatus(CPacketClientStatus packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
this.playerEntity.markPlayerActive();
CPacketClientStatus.State cpacketclientstatus$state = packetIn.getStatus();
switch (cpacketclientstatus$state)
{
case PERFORM_RESPAWN:
if (this.playerEntity.playerConqueredTheEnd)
{
this.playerEntity.playerConqueredTheEnd = false;
this.playerEntity = this.serverController.getPlayerList().recreatePlayerEntity(this.playerEntity, 0, true);
}
else
{
if (this.playerEntity.getHealth() > 0.0F)
{
return;
}
this.playerEntity = this.serverController.getPlayerList().recreatePlayerEntity(this.playerEntity, playerEntity.dimension, false);
if (this.serverController.isHardcore())
{
this.playerEntity.setGameType(GameType.SPECTATOR);
this.playerEntity.getServerWorld().getGameRules().setOrCreateGameRule("spectatorsGenerateChunks", "false");
}
}
break;
case REQUEST_STATS:
this.playerEntity.getStatFile().sendStats(this.playerEntity);
break;
case OPEN_INVENTORY_ACHIEVEMENT:
this.playerEntity.addStat(AchievementList.OPEN_INVENTORY);
}
}
项目:CustomWorldGen
文件:PlayerControllerMP.java
/**
* Attacks an entity
*/
public void attackEntity(EntityPlayer playerIn, Entity targetEntity)
{
this.syncCurrentPlayItem();
this.connection.sendPacket(new CPacketUseEntity(targetEntity));
if (this.currentGameType != GameType.SPECTATOR)
{
playerIn.attackTargetEntityWithCurrentItem(targetEntity);
playerIn.resetCooldown();
}
}
项目:Backmemed
文件:PlayerInteractionManager.java
public void setGameType(GameType type)
{
this.gameType = type;
type.configurePlayerCapabilities(this.thisPlayerMP.capabilities);
this.thisPlayerMP.sendPlayerAbilities();
this.thisPlayerMP.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.UPDATE_GAME_MODE, new EntityPlayerMP[] {this.thisPlayerMP}));
this.theWorld.updateAllPlayersSleepingFlag();
}
项目:CustomWorldGen
文件:PlayerInteractionManager.java
public void setGameType(GameType type)
{
this.gameType = type;
type.configurePlayerCapabilities(this.thisPlayerMP.capabilities);
this.thisPlayerMP.sendPlayerAbilities();
this.thisPlayerMP.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.UPDATE_GAME_MODE, new EntityPlayerMP[] {this.thisPlayerMP}));
this.theWorld.updateAllPlayersSleepingFlag();
}
项目:Backmemed
文件:CommandDefaultGameMode.java
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length <= 0)
{
throw new WrongUsageException("commands.defaultgamemode.usage", new Object[0]);
}
else
{
GameType gametype = this.getGameModeFromCommand(sender, args[0]);
this.setDefaultGameType(gametype, server);
notifyCommandListener(sender, this, "commands.defaultgamemode.success", new Object[] {new TextComponentTranslation("gameMode." + gametype.getName(), new Object[0])});
}
}
项目:Backmemed
文件:CommandDefaultGameMode.java
/**
* Set the default game type for the server. Also propogate the changes to all players if the server is set to force
* game mode
*/
protected void setDefaultGameType(GameType gameType, MinecraftServer server)
{
server.setGameType(gameType);
if (server.getForceGamemode())
{
for (EntityPlayerMP entityplayermp : server.getPlayerList().getPlayerList())
{
entityplayermp.setGameType(gameType);
}
}
}
项目:CustomWorldGen
文件:CommandDefaultGameMode.java
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length <= 0)
{
throw new WrongUsageException("commands.defaultgamemode.usage", new Object[0]);
}
else
{
GameType gametype = this.getGameModeFromCommand(sender, args[0]);
this.setDefaultGameType(gametype, server);
notifyCommandListener(sender, this, "commands.defaultgamemode.success", new Object[] {new TextComponentTranslation("gameMode." + gametype.getName(), new Object[0])});
}
}
项目:Backmemed
文件:CommandGameMode.java
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length <= 0)
{
throw new WrongUsageException("commands.gamemode.usage", new Object[0]);
}
else
{
GameType gametype = this.getGameModeFromCommand(sender, args[0]);
EntityPlayer entityplayer = args.length >= 2 ? getPlayer(server, sender, args[1]) : getCommandSenderAsPlayer(sender);
entityplayer.setGameType(gametype);
ITextComponent itextcomponent = new TextComponentTranslation("gameMode." + gametype.getName(), new Object[0]);
if (sender.getEntityWorld().getGameRules().getBoolean("sendCommandFeedback"))
{
entityplayer.addChatMessage(new TextComponentTranslation("gameMode.changed", new Object[] {itextcomponent}));
}
if (entityplayer == sender)
{
notifyCommandListener(sender, this, 1, "commands.gamemode.success.self", new Object[] {itextcomponent});
}
else
{
notifyCommandListener(sender, this, 1, "commands.gamemode.success.other", new Object[] {entityplayer.getName(), itextcomponent});
}
}
}
项目:CustomWorldGen
文件:EntityPlayerMP.java
@SuppressWarnings("unused")
public EntityPlayerMP(MinecraftServer server, WorldServer worldIn, GameProfile profile, PlayerInteractionManager interactionManagerIn)
{
super(worldIn, profile);
interactionManagerIn.thisPlayerMP = this;
this.interactionManager = interactionManagerIn;
BlockPos blockpos = worldIn.provider.getRandomizedSpawnPoint();
if (false && !worldIn.provider.getHasNoSky() && worldIn.getWorldInfo().getGameType() != GameType.ADVENTURE)
{
int i = Math.max(0, server.getSpawnRadius(worldIn));
int j = MathHelper.floor_double(worldIn.getWorldBorder().getClosestDistance((double)blockpos.getX(), (double)blockpos.getZ()));
if (j < i)
{
i = j;
}
if (j <= 1)
{
i = 1;
}
blockpos = worldIn.getTopSolidOrLiquidBlock(blockpos.add(this.rand.nextInt(i * 2 + 1) - i, 0, this.rand.nextInt(i * 2 + 1) - i));
}
this.mcServer = server;
this.statsFile = server.getPlayerList().getPlayerStatsFile(this);
this.stepHeight = 0.0F;
this.moveToBlockPosAndAngles(blockpos, 0.0F, 0.0F);
while (!worldIn.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty() && this.posY < 255.0D)
{
this.setPosition(this.posX, this.posY + 1.0D, this.posZ);
}
}
项目:harshencastle
文件:MessagePacketRingUpdate.java
@Override
public void onReceived(MessagePacketRingUpdate message, EntityPlayer player) {
if(message.ringType < 2)
{
ArrayList<Item> ringTypeItem = new ArrayList<Item>();
ringTypeItem.add(HarshenItems.TELERING);
ringTypeItem.add(HarshenItems.MINERING);
if(HarshenUtils.containsItem(player,ringTypeItem.get(message.ringType)))
{
World world = player.world;
Vec3d vec = new Vec3d(player.posX + (player.getLookVec().x * 4f),
player.posY + (player.getLookVec().y * 4f), player.posZ + (player.getLookVec().z* 4f));
BlockPos blockpos = message.ringType == 0? HarshenUtils.getTopBlock(world, vec) : HarshenUtils.getBottomBlockAir(world, vec);
Vec3d vecPos = new Vec3d(blockpos).addVector(0.5, 0, 0.5);
if(blockpos.getY() != -1 && player.getFoodStats().getFoodLevel() > 0)
{
((EntityPlayerMP)player).velocityChanged = true;
((EntityPlayerMP)player).fallDistance = 0;
HarshenNetwork.sendToPlayer(player, new MessagePacketPlayerTeleportEffects(vecPos));
((EntityPlayerMP)player).setPositionAndUpdate(vecPos.x, vecPos.y, vecPos.z);
world.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
player.playSound(SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, 1.0F, 1.0F);
player.addExhaustion(0.5F);
HarshenUtils.damageFirstOccuringItem(player, ringTypeItem.get(message.ringType));
}
}
}
else if(message.ringType == 2 && HarshenUtils.containsItem(player, HarshenItems.COMBAT_PENDANT))
{
EntityLivingBase entityToAttack = HarshenUtils.getFirstEntityInDirection(player.world, player.getPositionVector(), player.getLookVec().normalize(), 5, EntityLivingBase.class);
if(entityToAttack == null)
{
List<EntityLivingBase> list = player.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(player.posX - 4d, player.posY - 4d, player.posZ - 4d, player.posX + 4d, player.posY + 4d, player.posZ + 4d));
if(!list.isEmpty())
entityToAttack = list.get(0);
}
if(!player.equals(entityToAttack) && (entityToAttack != null || (entityToAttack instanceof EntityPlayerMP && player.canAttackPlayer((EntityPlayerMP)entityToAttack)
&& HarshenUtils.toArray(GameType.SURVIVAL, GameType.ADVENTURE).contains(((EntityPlayerMP)entityToAttack).interactionManager.getGameType()))))
{
Vec3d position = entityToAttack.getPositionVector();
Vec3d playerPosNoY = position.addVector(movePos(), 0, movePos());
Vec3d pos = new Vec3d(playerPosNoY.x, HarshenUtils.getTopBlock(player.world, new BlockPos(playerPosNoY)).getY(), playerPosNoY.z);
double d0 = position.x - pos.x;
double d1 = position.y - (pos.y + (double)player.getEyeHeight() - entityToAttack.height / 2f + 0.1f);
double d2 = position.z - pos.z;
double d3 = (double)MathHelper.sqrt(d0 * d0 + d2 * d2);
float yaw = (float)(MathHelper.atan2(d2, d0) * (180D / Math.PI)) - 90.0F;
float pitch = (float)(-(MathHelper.atan2(d1, d3) * (180D / Math.PI)));
((EntityPlayerMP)player).velocityChanged = true;
((EntityPlayerMP)player).connection.setPlayerLocation(pos.x, pos.y, pos.z, yaw, pitch);
}
}
}
项目:harshencastle
文件:RingOfFlight.java
private boolean shouldBeOn(EntityPlayer player, boolean _default)
{
return HarshenUtils.toArray(GameType.ADVENTURE, GameType.SURVIVAL).contains(!player.world.isRemote ?
((EntityPlayerMP)player).interactionManager.getGameType() : net.minecraft.client.Minecraft.getMinecraft().playerController.getCurrentGameType())
? _default : player.capabilities.allowFlying;
}