本文整理汇总了Java中net.minecraft.world.GameType类的典型用法代码示例。如果您正苦于以下问题:Java GameType类的具体用法?Java GameType怎么用?Java GameType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GameType类属于net.minecraft.world包,在下文中一共展示了GameType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onWorldTick
import net.minecraft.world.GameType; //导入依赖的package包/类
@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;
}
}
}
示例2: attackEntity
import net.minecraft.world.GameType; //导入依赖的package包/类
/**
* 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();
}
}
示例3: setGameType
import net.minecraft.world.GameType; //导入依赖的package包/类
/**
* 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();
}
示例4: readPacketData
import net.minecraft.world.GameType; //导入依赖的package包/类
/**
* 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();
}
示例5: doVoidFogParticles
import net.minecraft.world.GameType; //导入依赖的package包/类
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);
}
}
示例6: readEntityFromNBT
import net.minecraft.world.GameType; //导入依赖的package包/类
/**
* (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")));
}
}
}
示例7: setGameType
import net.minecraft.world.GameType; //导入依赖的package包/类
@Override
public void setGameType(GameType gameType) {
if (m_realPlayer == null) {
super.setGameType(gameType);
} else {
syncToRealPlayer();
m_realPlayer.setGameType(gameType);
syncPublicFieldsFromReal();
}
}
示例8: setGameType
import net.minecraft.world.GameType; //导入依赖的package包/类
@Override
public void setGameType(GameType gameType) {
if (m_realPlayer == null) {
super.setGameType(gameType);
} else {
m_realPlayer.setGameType(gameType);
}
}
示例9: HookedIntegratedPlayerList
import net.minecraft.world.GameType; //导入依赖的package包/类
@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);
}
示例10: TeleportToPlayer
import net.minecraft.world.GameType; //导入依赖的package包/类
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()));
}
}
}
示例11: isSpectator
import net.minecraft.world.GameType; //导入依赖的package包/类
/**
* 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;
}
示例12: attackTargetEntityWithCurrentItem
import net.minecraft.world.GameType; //导入依赖的package包/类
/**
* 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);
}
}
示例13: processRightClick
import net.minecraft.world.GameType; //导入依赖的package包/类
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();
}
}
}
示例14: interactWithEntity
import net.minecraft.world.GameType; //导入依赖的package包/类
/**
* 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);
}
示例15: doVoidFogParticles
import net.minecraft.world.GameType; //导入依赖的package包/类
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);
}
}