本文整理汇总了Java中net.minecraft.world.GameType.SPECTATOR属性的典型用法代码示例。如果您正苦于以下问题:Java GameType.SPECTATOR属性的具体用法?Java GameType.SPECTATOR怎么用?Java GameType.SPECTATOR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.minecraft.world.GameType
的用法示例。
在下文中一共展示了GameType.SPECTATOR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setGameType
/**
* 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();
}
示例2: attackEntity
/**
* 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: isDrawBlockOutline
private boolean isDrawBlockOutline()
{
if (!this.drawBlockOutline)
{
return false;
}
else
{
Entity entity = this.mc.getRenderViewEntity();
boolean flag = entity instanceof EntityPlayer && !this.mc.gameSettings.hideGUI;
if (flag && !((EntityPlayer)entity).capabilities.allowEdit)
{
ItemStack itemstack = ((EntityPlayer)entity).getHeldItemMainhand();
if (this.mc.objectMouseOver != null && this.mc.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK)
{
BlockPos blockpos = this.mc.objectMouseOver.getBlockPos();
Block block = this.mc.theWorld.getBlockState(blockpos).getBlock();
if (this.mc.playerController.getCurrentGameType() == GameType.SPECTATOR)
{
flag = block.hasTileEntity(this.mc.theWorld.getBlockState(blockpos)) && this.mc.theWorld.getTileEntity(blockpos) instanceof IInventory;
}
else
{
flag = itemstack != null && (itemstack.canDestroy(block) || itemstack.canPlaceOn(block));
}
}
}
return flag;
}
}
示例4: interactWithEntity
/**
* Handles right clicking an entity, sends a packet to the server.
*/
public EnumActionResult interactWithEntity(EntityPlayer player, Entity target, EnumHand heldItem)
{
//-ZMod-?-----------------------------------------------------
if (!ZHandle.handle("checkReachUse", target ,true)) return EnumActionResult.FAIL;
//------------------------------------------------------------
this.syncCurrentPlayItem();
this.connection.sendPacket(new CPacketUseEntity(target, heldItem));
return this.currentGameType == GameType.SPECTATOR ? EnumActionResult.PASS : player.func_190775_a(target, heldItem);
}
示例5: attackTargetEntityWithCurrentItem
/**
* 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);
}
}
示例6: interactWithEntity
/**
* 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);
}
示例7: TeleportToPlayer
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()));
}
}
}
示例8: processRightClick
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();
}
}
}
示例9: isSpectator
/**
* Returns true if the player is in spectator mode.
*/
public boolean isSpectator() {
NetworkPlayerInfo networkplayerinfo = Minecraft.getMinecraft().getConnection().getPlayerInfo(this.getGameProfile().getId());
return networkplayerinfo != null && networkplayerinfo.getGameType() == GameType.SPECTATOR;
}
示例10: onBlockClicked
/**
* If not creative, it calls sendBlockBreakProgress until the block is broken first. tryHarvestBlock can also be the
* result of this call.
*/
public void onBlockClicked(BlockPos pos, EnumFacing side)
{
if (this.isCreative())
{
if (!this.theWorld.extinguishFire((EntityPlayer)null, pos, side))
{
this.tryHarvestBlock(pos);
}
}
else
{
IBlockState iblockstate = this.theWorld.getBlockState(pos);
Block block = iblockstate.getBlock();
if (this.gameType.isAdventure())
{
if (this.gameType == GameType.SPECTATOR)
{
return;
}
if (!this.thisPlayerMP.isAllowEdit())
{
ItemStack itemstack = this.thisPlayerMP.getHeldItemMainhand();
if (itemstack.func_190926_b())
{
return;
}
if (!itemstack.canDestroy(block))
{
return;
}
}
}
this.theWorld.extinguishFire((EntityPlayer)null, pos, side);
this.initialDamage = this.curblockDamage;
float f = 1.0F;
if (iblockstate.getMaterial() != Material.AIR)
{
block.onBlockClicked(this.theWorld, pos, this.thisPlayerMP);
f = iblockstate.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.world, pos);
}
if (iblockstate.getMaterial() != Material.AIR && f >= 1.0F)
{
this.tryHarvestBlock(pos);
}
else
{
this.isDestroyingBlock = true;
this.destroyPos = pos;
int i = (int)(f * 10.0F);
this.theWorld.sendBlockBreakProgress(this.thisPlayerMP.getEntityId(), pos, i);
this.durabilityRemainingOnBlock = i;
}
}
}
示例11: isSpectator
/**
* None
*/
public boolean isSpectator()
{
return this.currentGameType == GameType.SPECTATOR;
}
示例12: isSpectator
/**
* Returns true if the player is in spectator mode.
*/
public boolean isSpectator()
{
NetworkPlayerInfo networkplayerinfo = Minecraft.getMinecraft().getConnection().getPlayerInfo(this.getGameProfile().getId());
return networkplayerinfo != null && networkplayerinfo.getGameType() == GameType.SPECTATOR;
}
示例13: isSpectatorMode
public boolean isSpectatorMode()
{
return this.currentGameType == GameType.SPECTATOR;
}
示例14: processRightClick
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, ItemStack stack, EnumHand hand)
{
if (this.gameType == GameType.SPECTATOR)
{
return EnumActionResult.PASS;
}
else 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;
int j = stack.getMetadata();
ActionResult<ItemStack> actionresult = stack.useItemRightClick(worldIn, player, hand);
ItemStack itemstack = (ItemStack)actionresult.getResult();
if (itemstack == stack && itemstack.stackSize == i && itemstack.getMaxItemUseDuration() <= 0 && itemstack.getMetadata() == j)
{
return actionresult.getType();
}
else
{
player.setHeldItem(hand, itemstack);
if (this.isCreative())
{
itemstack.stackSize = i;
if (itemstack.isItemStackDamageable())
{
itemstack.setItemDamage(j);
}
}
if (itemstack.stackSize == 0)
{
player.setHeldItem(hand, (ItemStack)null);
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, itemstack, hand);
}
if (!player.isHandActive())
{
((EntityPlayerMP)player).sendContainerToPlayer(player.inventoryContainer);
}
return actionresult.getType();
}
}
}
示例15: processRightClick
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, ItemStack stack, EnumHand hand)
{
if (this.gameType == GameType.SPECTATOR)
{
return EnumActionResult.PASS;
}
else if (player.getCooldownTracker().hasCooldown(stack.getItem()))
{
return EnumActionResult.PASS;
}
else
{
int i = stack.func_190916_E();
int j = stack.getMetadata();
ActionResult<ItemStack> actionresult = stack.useItemRightClick(worldIn, player, hand);
ItemStack itemstack = (ItemStack)actionresult.getResult();
if (itemstack == stack && itemstack.func_190916_E() == i && itemstack.getMaxItemUseDuration() <= 0 && itemstack.getMetadata() == j)
{
return actionresult.getType();
}
else if (actionresult.getType() == EnumActionResult.FAIL && itemstack.getMaxItemUseDuration() > 0 && !player.isHandActive())
{
return actionresult.getType();
}
else
{
player.setHeldItem(hand, itemstack);
if (this.isCreative())
{
itemstack.func_190920_e(i);
if (itemstack.isItemStackDamageable())
{
itemstack.setItemDamage(j);
}
}
if (itemstack.func_190926_b())
{
player.setHeldItem(hand, ItemStack.field_190927_a);
}
if (!player.isHandActive())
{
((EntityPlayerMP)player).sendContainerToPlayer(player.inventoryContainer);
}
return actionresult.getType();
}
}
}