Java Code Examples for net.minecraft.entity.player.EntityPlayer

The following are top voted examples for showing how to use net.minecraft.entity.player.EntityPlayer. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: BaseClient   File: EntityEnderman.java   Source Code and License 7 votes vote down vote up
/**
 * Checks to see if this enderman should be attacking this player
 */
private boolean shouldAttackPlayer(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.armorInventory[3];

    if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.pumpkin))
    {
        return false;
    }
    else
    {
        Vec3 vec3 = player.getLook(1.0F).normalize();
        Vec3 vec31 = new Vec3(this.posX - player.posX, this.getEntityBoundingBox().minY + (double)(this.height / 2.0F) - (player.posY + (double)player.getEyeHeight()), this.posZ - player.posZ);
        double d0 = vec31.lengthVector();
        vec31 = vec31.normalize();
        double d1 = vec3.dotProduct(vec31);
        return d1 > 1.0D - 0.025D / d0 ? player.canEntityBeSeen(this) : false;
    }
}
 
Example 2
Project: BaseClient   File: EntitySheep.java   Source Code and License 6 votes vote down vote up
public EntitySheep(World worldIn)
{
    super(worldIn);
    this.setSize(0.9F, 1.3F);
    ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityAIPanic(this, 1.25D));
    this.tasks.addTask(2, new EntityAIMate(this, 1.0D));
    this.tasks.addTask(3, new EntityAITempt(this, 1.1D, Items.wheat, false));
    this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D));
    this.tasks.addTask(5, this.entityAIEatGrass);
    this.tasks.addTask(6, new EntityAIWander(this, 1.0D));
    this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
    this.tasks.addTask(8, new EntityAILookIdle(this));
    this.inventoryCrafting.setInventorySlotContents(0, new ItemStack(Items.dye, 1, 0));
    this.inventoryCrafting.setInventorySlotContents(1, new ItemStack(Items.dye, 1, 0));
}
 
Example 3
Project: Loot-Slash-Conquer   File: PacketClassGui.java   Source Code and License 6 votes vote down vote up
@Override
public IMessage onMessage(final PacketClassGui message, final MessageContext ctx) 
{			
	IThreadListener mainThread = Minecraft.getMinecraft();
	mainThread.addScheduledTask(new Runnable()
	{
		@Override
		public void run() 
		{
			EntityPlayer player = Minecraft.getMinecraft().player;
			PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
			
			if (playerInfo != null && playerInfo.getPlayerClass() == 0)
			{
				player.openGui(LootSlashConquer.instance, GuiHandler.CLASS_SELECTION, player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ());
			}
		}
	});
	
	return null;
}
 
Example 4
Project: Zombe-Modpack   File: Motion.java   Source Code and License 6 votes vote down vote up
private static void emulateSendMotion(EntityPlayer player) {
    // emulate client player's sendMotion
    Vec3d newPosition = null;
    if (player.isRiding()) {
        // needs improvement
        newPosition = getPosition(player);
        emulateHandleMotion(player, newPosition, getOnGround(player));
    } else if (getView() == player) {
        double dx = getX(sentPosition) - getX(player);
        double dy = getY(sentPosition) - getY(player);
        double dz = getZ(sentPosition) - getZ(player);
        boolean sync = (dx*dx + dy*dy + dz*dz > 9.0E-4D
            || ticksForForceSync >= 20);
        ++ticksForForceSync;
        if (sync) {
            newPosition = sentPosition = getPosition(player);
            ticksForForceSync = 0;
        }
        emulateHandleMotion(player, newPosition, getOnGround(player));
    }
}
 
Example 5
Project: IceMod   File: IceFragment.java   Source Code and License 6 votes vote down vote up
/** Makes your Item Enchanted when it is crafted */
public void onCreated(ItemStack item, World world, EntityPlayer player) 
{
    item.addEnchantment(Enchantment.sharpness, 5);
    // Replace the "." after "Enchantment" to see options
    // The number is the Enchantment Level
}
 
Example 6
Project: Clef   File: Track.java   Source Code and License 6 votes vote down vote up
@SideOnly(Side.CLIENT)
public void findPlayers()
{
    Iterator<String> ite = playersNames.iterator();
    while(ite.hasNext())
    {
        String s = ite.next();
        if(Minecraft.getMinecraft().world != null)
        {
            EntityPlayer player = Minecraft.getMinecraft().world.getPlayerEntityByName(s);
            if(player != null && player.isEntityAlive())
            {
                players.put(player, 0);
                ite.remove();
            }
        }
    }
}
 
Example 7
Project: FirstAid   File: DamageDistribution.java   Source Code and License 6 votes vote down vote up
@Override
public float distributeDamage(float damage, @Nonnull EntityPlayer player, @Nonnull DamageSource source, boolean addStat) {
    AbstractPlayerDamageModel damageModel = PlayerDataManager.getDamageModel(player);
    for (Pair<EntityEquipmentSlot, EnumPlayerPart[]> pair : getPartList()) {
        EntityEquipmentSlot slot = pair.getLeft();
        damage = ArmorUtils.applyArmor(player, player.getItemStackFromSlot(slot), source, damage, slot);
        if (damage <= 0F)
            return 0F;
        damage = ArmorUtils.applyEnchantmentModifiers(player.getItemStackFromSlot(slot), source, damage);
        if (damage <= 0F)
            return 0F;

        damage = distributeDamageOnParts(damage, damageModel, pair.getRight(), player, addStat);
        if (damage == 0F)
            break;
    }
    return damage;
}
 
Example 8
Project: CustomWorldGen   File: ItemElytra.java   Source Code and License 6 votes vote down vote up
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(itemStackIn);
    ItemStack itemstack = playerIn.getItemStackFromSlot(entityequipmentslot);

    if (itemstack == null)
    {
        playerIn.setItemStackToSlot(entityequipmentslot, itemStackIn.copy());
        itemStackIn.stackSize = 0;
        return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
    }
    else
    {
        return new ActionResult(EnumActionResult.FAIL, itemStackIn);
    }
}
 
Example 9
Project: BaseClient   File: ServerConfigurationManager.java   Source Code and License 6 votes vote down vote up
public void sendMessageToAllTeamMembers(EntityPlayer player, IChatComponent message)
{
    Team team = player.getTeam();

    if (team != null)
    {
        for (String s : team.getMembershipCollection())
        {
            EntityPlayerMP entityplayermp = this.getPlayerByUsername(s);

            if (entityplayermp != null && entityplayermp != player)
            {
                entityplayermp.addChatMessage(message);
            }
        }
    }
}
 
Example 10
Project: pnc-repressurized   File: ItemRemote.java   Source Code and License 6 votes vote down vote up
private boolean isAllowedToEdit(EntityPlayer player, ItemStack remote) {
    NBTTagCompound tag = remote.getTagCompound();
    if (tag != null) {
        if (tag.hasKey("securityX")) {
            int x = tag.getInteger("securityX");
            int y = tag.getInteger("securityY");
            int z = tag.getInteger("securityZ");
            int dimensionId = tag.getInteger("securityDimension");
            WorldServer world = DimensionManager.getWorld(dimensionId);
            if (world != null) {
                TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
                if (te instanceof TileEntitySecurityStation) {
                    boolean canAccess = ((TileEntitySecurityStation) te).doesAllowPlayer(player);
                    if (!canAccess) {
                        player.sendStatusMessage(new TextComponentTranslation("gui.remote.noEditRights", x, y, z), false);
                    }
                    return canAccess;
                }
            }
        }
    }
    return true;
}
 
Example 11
Project: Backmemed   File: TileEntityStructure.java   Source Code and License 6 votes vote down vote up
public boolean usedBy(EntityPlayer player)
{
    if (!player.canUseCommandBlock())
    {
        return false;
    }
    else
    {
        if (player.getEntityWorld().isRemote)
        {
            player.openEditStructure(this);
        }

        return true;
    }
}
 
Example 12
Project: Backmemed   File: ItemSlab.java   Source Code and License 6 votes vote down vote up
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack)
{
    BlockPos blockpos = pos;
    IProperty<?> iproperty = this.singleSlab.getVariantProperty();
    Comparable<?> comparable = this.singleSlab.getTypeForItem(stack);
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() == this.singleSlab)
    {
        boolean flag = iblockstate.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP;

        if ((side == EnumFacing.UP && !flag || side == EnumFacing.DOWN && flag) && comparable == iblockstate.getValue(iproperty))
        {
            return true;
        }
    }

    pos = pos.offset(side);
    IBlockState iblockstate1 = worldIn.getBlockState(pos);
    return iblockstate1.getBlock() == this.singleSlab && comparable == iblockstate1.getValue(iproperty) ? true : super.canPlaceBlockOnSide(worldIn, blockpos, side, player, stack);
}
 
Example 13
Project: CustomWorldGen   File: CommandBlockBaseLogic.java   Source Code and License 6 votes vote down vote up
public boolean tryOpenEditCommandBlock(EntityPlayer playerIn)
{
    if (!playerIn.canUseCommandBlock())
    {
        return false;
    }
    else
    {
        if (playerIn.getEntityWorld().isRemote)
        {
            playerIn.displayGuiEditCommandCart(this);
        }

        return true;
    }
}
 
Example 14
Project: BaseClient   File: BlockFlowerPot.java   Source Code and License 5 votes vote down vote up
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
    super.onBlockHarvested(worldIn, pos, state, player);

    if (player.capabilities.isCreativeMode)
    {
        TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);

        if (tileentityflowerpot != null)
        {
            tileentityflowerpot.setFlowerPotData((Item)null, 0);
        }
    }
}
 
Example 15
Project: CustomWorldGen   File: ItemTooltipEvent.java   Source Code and License 5 votes vote down vote up
/**
 * This event is fired in {@link ItemStack#getTooltip(EntityPlayer, boolean)}, which in turn is called from it's respective GUIContainer.
 */
public ItemTooltipEvent(ItemStack itemStack, EntityPlayer entityPlayer, List<String> toolTip, boolean showAdvancedItemTooltips)
{
    super(entityPlayer);
    this.itemStack = itemStack;
    this.toolTip = toolTip;
    this.showAdvancedItemTooltips = showAdvancedItemTooltips;
}
 
Example 16
Project: BaseClient   File: EntitySheep.java   Source Code and License 5 votes vote down vote up
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();

    if (itemstack != null && itemstack.getItem() == Items.shears && !this.getSheared() && !this.isChild())
    {
        if (!this.worldObj.isRemote)
        {
            this.setSheared(true);
            int i = 1 + this.rand.nextInt(3);

            for (int j = 0; j < i; ++j)
            {
                EntityItem entityitem = this.entityDropItem(new ItemStack(Item.getItemFromBlock(Blocks.wool), 1, this.getFleeceColor().getMetadata()), 1.0F);
                entityitem.motionY += (double)(this.rand.nextFloat() * 0.05F);
                entityitem.motionX += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
                entityitem.motionZ += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
            }
        }

        itemstack.damageItem(1, player);
        this.playSound("mob.sheep.shear", 1.0F, 1.0F);
    }

    return super.interact(player);
}
 
Example 17
Project: Mods   File: TF2ProjectileHandler.java   Source Code and License 5 votes vote down vote up
@Override
public IMessage onMessage(final PredictionMessage message, MessageContext ctx) {
	final EntityPlayer shooter = ctx.getServerHandler().player;
	// ItemStack stack=shooter.getHeldItem(EnumHand.MAIN_HAND);
	((WorldServer) shooter.world).addScheduledTask(new Runnable() {

		@Override
		public void run() {
			shooter.getCapability(TF2weapons.WEAPONS_CAP, null).predictionList.add(message);
			message.time=shooter.world.getTotalWorldTime();
		}

	});
	return null;
}
 
Example 18
Project: CustomWorldGen   File: BlockDoublePlant.java   Source Code and License 5 votes vote down vote up
private boolean onHarvest(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
    BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)state.getValue(VARIANT);

    if (blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS)
    {
        return false;
    }
    else
    {
        player.addStat(StatList.getBlockStats(this));
        return true;
    }
}
 
Example 19
Project: Bewitchment   File: ItemSalt.java   Source Code and License 5 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	final boolean flag = worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos);
	final BlockPos blockpos = flag ? pos : pos.offset(facing);

	ItemStack stack = playerIn.getHeldItem(hand);
	if (playerIn.canPlayerEdit(blockpos, facing, stack) && worldIn.mayPlace(worldIn.getBlockState(blockpos).getBlock(), blockpos, false, facing, playerIn) && ModBlocks.salt_barrier.canPlaceBlockAt(worldIn, blockpos)) {
		stack.shrink(1);
		worldIn.setBlockState(blockpos, ModBlocks.salt_barrier.getDefaultState());
		return EnumActionResult.SUCCESS;
	} else {
		return EnumActionResult.FAIL;
	}
}
 
Example 20
Project: ProgressiveDifficulty   File: ServerCommand.java   Source Code and License 5 votes vote down vote up
private void sendChat(ICommandSender sender, String[] msg){
    EntityPlayer player = (EntityPlayer)sender.getCommandSenderEntity();
    for (String str : msg)
    {
        TextComponentString line = new TextComponentString(str);
        player.sendMessage(line);
    }
}
 
Example 21
Project: minecraft-quiverbow   File: EnderQuartzClip.java   Source Code and License 5 votes vote down vote up
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean unknown) 
{
	list.add(EnumChatFormatting.BLUE + "Ender Quartz: " + (this.getMaxDamage() - stack.getItemDamage()) + " / " + this.getMaxDamage());
	list.add(EnumChatFormatting.YELLOW + "Use magazine to fill it with");
	list.add(EnumChatFormatting.YELLOW + "Ender Pearls and Quartz.");
	list.add("A clip full of");
	list.add("quartz-encased ender pearls.");
	
	if (!player.inventory.hasItem(Items.ender_pearl)) { list.add(EnumChatFormatting.RED + "You don't have ender pearls."); }
	if (!player.inventory.hasItem(Items.quartz)) { list.add(EnumChatFormatting.RED + "You don't have quartz."); }
	if (player.capabilities.isCreativeMode) { list.add(EnumChatFormatting.RED + "Does not work in creative mode."); }
}
 
Example 22
Project: ExPetrum   File: ItemWateringCan.java   Source Code and License 5 votes vote down vote up
public void tryHydrateBlock(EntityPlayer player, int tier, BlockPos pos, World w, IBlockState state, IFluidHandlerItem cap, ItemStack is)
{
	while ((state.getMaterial() == Material.PLANTS || w.isAirBlock(pos)) && pos.getY() > 0)
	{
		pos = pos.down();
		state = w.getBlockState(pos);
	}
	
	if (state.getBlock() instanceof IAcceptsWaterCan)
	{
		((IAcceptsWaterCan)state.getBlock()).acceptWatering(player, w, pos, state, cap, is, tier);
	}
	
	w.spawnParticle(EnumParticleTypes.WATER_SPLASH, pos.getX() + w.rand.nextFloat(), pos.getY() + 1, pos.getZ() + w.rand.nextFloat(), 0, 0, 0);
}
 
Example 23
Project: minecraft-territorialdealings   File: StartFactionDeed.java   Source Code and License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
{
	super.addInformation(stack, player, list, par4);

	list.add("'The start of something great.'");
	list.add("Use this to create a new faction");
	list.add("in your current chunk.");
	list.add(ChatFormatting.YELLOW + "Each claimed chunk increases");
	list.add(ChatFormatting.YELLOW + "territory upkeep by 1.");
	list.add(ChatFormatting.RED + "Used up on successful creation.");
   }
 
Example 24
Project: BaseClient   File: EntityLivingBase.java   Source Code and License 5 votes vote down vote up
/**
 * returns true if this entity is by a ladder, false otherwise
 */
public boolean isOnLadder()
{
    int i = MathHelper.floor_double(this.posX);
    int j = MathHelper.floor_double(this.getEntityBoundingBox().minY);
    int k = MathHelper.floor_double(this.posZ);
    Block block = this.worldObj.getBlockState(new BlockPos(i, j, k)).getBlock();
    return (block == Blocks.ladder || block == Blocks.vine) && (!(this instanceof EntityPlayer) || !((EntityPlayer)this).isSpectator());
}
 
Example 25
Project: Backmemed   File: Entity.java   Source Code and License 5 votes vote down vote up
/**
 * Only used by renderer in EntityLivingBase subclasses.
 * Determines if an entity is visible or not to a specfic player, if the entity is normally invisible.
 * For EntityLivingBase subclasses, returning false when invisible will render the entity semitransparent.
 */
public boolean isInvisibleToPlayer(EntityPlayer player)
{
    if (player.isSpectator())
    {
        return false;
    }
    else
    {
        Team team = this.getTeam();
        return team != null && player != null && player.getTeam() == team && team.getSeeFriendlyInvisiblesEnabled() ? false : this.isInvisible();
    }
}
 
Example 26
Project: BaseClient   File: EntityCow.java   Source Code and License 5 votes vote down vote up
public EntityCow(World worldIn)
{
    super(worldIn);
    this.setSize(0.9F, 1.3F);
    ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityAIPanic(this, 2.0D));
    this.tasks.addTask(2, new EntityAIMate(this, 1.0D));
    this.tasks.addTask(3, new EntityAITempt(this, 1.25D, Items.wheat, false));
    this.tasks.addTask(4, new EntityAIFollowParent(this, 1.25D));
    this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
    this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
    this.tasks.addTask(7, new EntityAILookIdle(this));
}
 
Example 27
Project: BaseClient   File: Scoreboard.java   Source Code and License 5 votes vote down vote up
public void func_181140_a(Entity p_181140_1_)
{
    if (p_181140_1_ != null && !(p_181140_1_ instanceof EntityPlayer) && !p_181140_1_.isEntityAlive())
    {
        String s = p_181140_1_.getUniqueID().toString();
        this.removeObjectiveFromEntity(s, (ScoreObjective)null);
        this.removePlayerFromTeams(s);
    }
}
 
Example 28
Project: harshencastle   File: EnderBow.java   Source Code and License 5 votes vote down vote up
@Override
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) {
	if(getMaxItemUseDuration(stack) - timeLeft < 10)
		return;
	float f = ItemBow.getArrowVelocity(getMaxItemUseDuration(stack) - timeLeft);
	spawnThrownEntity(worldIn, entityLiving, 3f * f, new HarshenEnderArrow(f), new EntityThrowSpawnData(1).setIgnoreBlocks(true));
       worldIn.playSound((EntityPlayer)null, entityLiving.posX, entityLiving.posY, entityLiving.posZ, SoundEvents.ENTITY_ENDERMITE_AMBIENT, SoundCategory.PLAYERS, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
	stack.damageItem(1, entityLiving);
}
 
Example 29
Project: MeeCreeps   File: WorkerHelper.java   Source Code and License 5 votes vote down vote up
@Override
public boolean allowedToHarvest(IBlockState state, World world, BlockPos pos, EntityPlayer entityPlayer) {
    if (state.getBlock().getBlockHardness(state, world, pos) < 0) {
        return false;
    }
    if (!state.getBlock().canEntityDestroy(state, world, pos, entityPlayer)) {
        return false;
    }
    BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, state, entityPlayer);
    MinecraftForge.EVENT_BUS.post(event);
    if (event.isCanceled()) {
        return false;
    }
    return state.getBlock().canHarvestBlock(world, pos, entityPlayer);
}
 
Example 30
Project: Backmemed   File: EntityOcelot.java   Source Code and License 5 votes vote down vote up
protected void setupTamedAI()
{
    if (this.avoidEntity == null)
    {
        this.avoidEntity = new EntityAIAvoidEntity(this, EntityPlayer.class, 16.0F, 0.8D, 1.33D);
    }

    this.tasks.removeTask(this.avoidEntity);

    if (!this.isTamed())
    {
        this.tasks.addTask(4, this.avoidEntity);
    }
}
 
Example 31
Project: PowerProbe   File: MessageUsingProbe.java   Source Code and License 5 votes vote down vote up
private BlockPos addProbe(EntityPlayer player, MessageUsingProbe message) {
  BlockPos probePos = message.target.offset(message.side);
  if (isReplaceableBlockAt(player.world, probePos)) {
    player.world.setBlockState(probePos, BlockPowerProbe.INSTANCE.getDefaultState().withProperty(BlockPowerProbe.FACING, message.side));
    playSound(player);
  }
  return probePos;
}
 
Example 32
Project: harshencastle   File: GlassContainer.java   Source Code and License 5 votes vote down vote up
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
  {
if(!hasDrinkEffect(playerIn, handIn))
	return new ActionResult<ItemStack>(EnumActionResult.FAIL, playerIn.getHeldItem(handIn));
playerIn.setActiveHand(handIn);
      return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn));
  }
 
Example 33
Project: Backmemed   File: World.java   Source Code and License 5 votes vote down vote up
/**
 * Called when an entity is spawned in the world. This includes players.
 */
public boolean spawnEntityInWorld(Entity entityIn)
{
    int i = MathHelper.floor(entityIn.posX / 16.0D);
    int j = MathHelper.floor(entityIn.posZ / 16.0D);
    boolean flag = entityIn.forceSpawn;

    if (entityIn instanceof EntityPlayer)
    {
        flag = true;
    }

    if (!flag && !this.isChunkLoaded(i, j, false))
    {
        return false;
    }
    else
    {
        if (entityIn instanceof EntityPlayer)
        {
            EntityPlayer entityplayer = (EntityPlayer)entityIn;
            this.playerEntities.add(entityplayer);
            this.updateAllPlayersSleepingFlag();
        }

        this.getChunkFromChunkCoords(i, j).addEntity(entityIn);
        this.loadedEntityList.add(entityIn);
        this.onEntityAdded(entityIn);
        return true;
    }
}
 
Example 34
Project: minecraft-territorialdealings   File: StartFactionDeed.java   Source Code and License 5 votes vote down vote up
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
	if (world.isRemote) { return new ActionResult(EnumActionResult.PASS, stack); }	// Not doing this on client side

	BlockPos pos = new BlockPos(player.posX, player.posY, player.posZ);

	if (TerritoryHandler.tryToAddFaction(world, player, pos))
	{
		stack.stackSize -= 1;	// Success
	}

	return new ActionResult(EnumActionResult.PASS, stack);
}
 
Example 35
Project: Bewitchment   File: ItemTaglock.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("ConstantConditions")
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
	if (!world.isRemote) {
		RayTraceResult result = RayTraceHelper.rayTraceResult(player, RayTraceHelper.fromLookVec(player, 2), true, true);
		if (result != null && result.typeOfHit == ENTITY && result.entityHit instanceof EntityLivingBase) {
			setVictim(player.getHeldItem(hand), (EntityLivingBase) result.entityHit);
		}
	}
	return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
 
Example 36
Project: minecraft-quiverbow   File: GoldMagazine.java   Source Code and License 5 votes vote down vote up
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean unknown) 
{
	list.add(EnumChatFormatting.BLUE + "Gold Nuggets: " + (this.getMaxDamage() - stack.getItemDamage()) + " / " + this.getMaxDamage());
	list.add(EnumChatFormatting.YELLOW + "Use magazine to fill it with Gold Nuggets.");
	list.add(EnumChatFormatting.YELLOW + "Crouch-use to fill it with 8 Gold Nuggets.");
	list.add("A loading helper, full of gold nuggets.");
	
	if (!player.inventory.hasItem(Items.gold_nugget)) { list.add(EnumChatFormatting.RED + "You don't have gold nuggets."); }
	if (player.capabilities.isCreativeMode) { list.add(EnumChatFormatting.RED + "Does not work in creative mode."); }
}
 
Example 37
Project: pnc-repressurized   File: SemiBlockManager.java   Source Code and License 5 votes vote down vote up
public void breakSemiBlock(ISemiBlock semiBlock, EntityPlayer player) {
    if (!semiBlock.isInvalid()) {
        World world = semiBlock.getWorld();
        BlockPos pos = semiBlock.getPos();
        NonNullList<ItemStack> drops = NonNullList.create();
        semiBlock.addDrops(drops);
        for (ItemStack stack : drops) {
            EntityItem item = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack);
            world.spawnEntity(item);
            if (player != null) item.onCollideWithPlayer(player);
        }
        removeSemiBlock(semiBlock);
    }
}
 
Example 38
Project: GeneralLaymansAestheticSpyingScreen   File: PacketWirelessOrder.java   Source Code and License 5 votes vote down vote up
@Override
public void execute(Side side, EntityPlayer player)
{
    TileEntity te = player.getEntityWorld().getTileEntity(pos);
    if(te instanceof TileEntityGlassMaster && !((TileEntityGlassMaster)te).active)
    {
        ((TileEntityGlassMaster)te).wirelessPos = channel;
        te.markDirty();

        IBlockState state = player.getEntityWorld().getBlockState(pos);
        player.getEntityWorld().notifyBlockUpdate(pos, state, state, 3);
    }
}
 
Example 39
Project: minecraft-quiverbow   File: AA_Targeter.java   Source Code and License 5 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) 
{
	if (world.isRemote) { return stack; }	// Not doing this on client side
	
	this.doSingleFire(stack, world, player);	// Handing it over to the neutral firing function
	
	return stack;
}
 
Example 40
Project: ExPetrum   File: PlayerManager.java   Source Code and License 5 votes vote down vote up
public static void handleThirst(EntityPlayer player, IExPPlayer data, int skippedTicks)
{
	if (skippedTicks == 0)
	{
		handleThirstChange(player, data, 1);
	}
	else
	{
		for (int i = 0; i < skippedTicks; ++i)
		{
			handleThirstChange(player, data, 0.5F);
		}
	}
}
 
Example 41
Project: BaseClient   File: CommandMessage.java   Source Code and License 5 votes vote down vote up
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 2)
    {
        throw new WrongUsageException("commands.message.usage", new Object[0]);
    }
    else
    {
        EntityPlayer entityplayer = getPlayer(sender, args[0]);

        if (entityplayer == sender)
        {
            throw new PlayerNotFoundException("commands.message.sameTarget", new Object[0]);
        }
        else
        {
            IChatComponent ichatcomponent = getChatComponentFromNthArg(sender, args, 1, !(sender instanceof EntityPlayer));
            ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.message.display.incoming", new Object[] {sender.getDisplayName(), ichatcomponent.createCopy()});
            ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.message.display.outgoing", new Object[] {entityplayer.getDisplayName(), ichatcomponent.createCopy()});
            chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(Boolean.valueOf(true));
            chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(Boolean.valueOf(true));
            entityplayer.addChatMessage(chatcomponenttranslation);
            sender.addChatMessage(chatcomponenttranslation1);
        }
    }
}
 
Example 42
Project: CustomWorldGen   File: BlockDeadBush.java   Source Code and License 5 votes vote down vote up
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack)
{
    if (false && !worldIn.isRemote && stack != null && stack.getItem() == Items.SHEARS) // Forge: Noop
    {
        player.addStat(StatList.getBlockStats(this));
        spawnAsEntity(worldIn, pos, new ItemStack(Blocks.DEADBUSH, 1, 0));
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, te, stack);
    }
}
 
Example 43
Project: CustomWorldGen   File: ArrowNockEvent.java   Source Code and License 5 votes vote down vote up
public ArrowNockEvent(EntityPlayer player, ItemStack item, EnumHand hand, World world, boolean hasAmmo)
{
    super(player);
    this.bow = item;
    this.hand = hand;
    this.world = world;
    this.hasAmmo = hasAmmo;
}
 
Example 44
Project: MiningWells   File: TileEntityMiningWell.java   Source Code and License 4 votes vote down vote up
public boolean isUsableByPlayer(EntityPlayer player) {
	return player.getDistanceSq(pos.add(0.5f, 0.5f, 0.5f)) <= 64;
}
 
Example 45
Project: BaseClient   File: EntityEnderman.java   Source Code and License 4 votes vote down vote up
public AIFindPlayer(EntityEnderman p_i45842_1_)
{
    super(p_i45842_1_, EntityPlayer.class, true);
    this.enderman = p_i45842_1_;
}
 
Example 46
Project: Backmemed   File: TileEntityShulkerBox.java   Source Code and License 4 votes vote down vote up
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
{
    return new ContainerShulkerBox(playerInventory, this, playerIn);
}
 
Example 47
Project: CustomWorldGen   File: ContainerHorseInventory.java   Source Code and License 4 votes vote down vote up
/**
 * Determines whether supplied player can use this container
 */
public boolean canInteractWith(EntityPlayer playerIn)
{
    return this.horseInventory.isUseableByPlayer(playerIn) && this.theHorse.isEntityAlive() && this.theHorse.getDistanceToEntity(playerIn) < 8.0F;
}
 
Example 48
Project: BaseClient   File: MapData.java   Source Code and License 4 votes vote down vote up
public MapInfo(EntityPlayer player)
{
    this.entityplayerObj = player;
}
 
Example 49
Project: ExPetrum   File: ItemThrow.java   Source Code and License 4 votes vote down vote up
@Override
public boolean canExecute(EntityPlayer player, WeaponType currentWeapon, EnumWeaponWeight currentWeaponWeight, boolean invokedWithRightClick)
{
	return !invokedWithRightClick && player.getActiveItemStack().isEmpty() && currentWeapon.isAssociated(WeaponType.DAGGER) && currentWeaponWeight == EnumWeaponWeight.LIGHT;
}
 
Example 50
Project: FoodCraft-Reloaded   File: ContainerDrinkMachine.java   Source Code and License 4 votes vote down vote up
@Override
public boolean canInteractWith(@Nonnull EntityPlayer playerIn) {
    return true;
}
 
Example 51
Project: ProgressiveDifficulty   File: ChatUtil.java   Source Code and License 4 votes vote down vote up
/**
 * @see #wrap(String)
 * @see #sendNoSpam(EntityPlayer, ITextComponent...)
 */
public static void sendNoSpam(EntityPlayer player, String... lines)
{
    sendNoSpam(player, wrap(lines));
}
 
Example 52
Project: CustomWorldGen   File: GuiIngame.java   Source Code and License 4 votes vote down vote up
protected void renderMountHealth(ScaledResolution p_184047_1_)
{
    if (this.mc.getRenderViewEntity() instanceof EntityPlayer)
    {
        EntityPlayer entityplayer = (EntityPlayer)this.mc.getRenderViewEntity();
        Entity entity = entityplayer.getRidingEntity();

        if (entity instanceof EntityLivingBase)
        {
            this.mc.mcProfiler.endStartSection("mountHealth");
            EntityLivingBase entitylivingbase = (EntityLivingBase)entity;
            int i = (int)Math.ceil((double)entitylivingbase.getHealth());
            float f = entitylivingbase.getMaxHealth();
            int j = (int)(f + 0.5F) / 2;

            if (j > 30)
            {
                j = 30;
            }

            int k = p_184047_1_.getScaledHeight() - 39;
            int l = p_184047_1_.getScaledWidth() / 2 + 91;
            int i1 = k;
            int j1 = 0;

            for (boolean flag = false; j > 0; j1 += 20)
            {
                int k1 = Math.min(j, 10);
                j -= k1;

                for (int l1 = 0; l1 < k1; ++l1)
                {
                    int i2 = 52;
                    int j2 = 0;
                    int k2 = l - l1 * 8 - 9;
                    this.drawTexturedModalRect(k2, i1, 52 + j2 * 9, 9, 9, 9);

                    if (l1 * 2 + 1 + j1 < i)
                    {
                        this.drawTexturedModalRect(k2, i1, 88, 9, 9, 9);
                    }

                    if (l1 * 2 + 1 + j1 == i)
                    {
                        this.drawTexturedModalRect(k2, i1, 97, 9, 9, 9);
                    }
                }

                i1 -= 10;
            }
        }
    }
}
 
Example 53
Project: pnc-repressurized   File: HackableJukebox.java   Source Code and License 4 votes vote down vote up
@Override
public boolean canHack(IBlockAccess world, BlockPos pos, EntityPlayer player) {
    return world.getBlockState(pos).getValue(BlockJukebox.HAS_RECORD);
}
 
Example 54
Project: needtobreath   File: CommonProxy.java   Source Code and License 4 votes vote down vote up
public EntityPlayer getClientPlayer() {
    throw new IllegalStateException("This should only be called from client side");
}
 
Example 55
Project: HardcoreRevival   File: PlayerKnockedOutEvent.java   Source Code and License 4 votes vote down vote up
public PlayerKnockedOutEvent(EntityPlayer player, DamageSource source) {
	this.player = player;
	this.source = source;
}
 
Example 56
Project: pnc-repressurized   File: HackableWitch.java   Source Code and License 4 votes vote down vote up
@Override
public boolean canHack(Entity entity, EntityPlayer player) {
    return true;
}
 
Example 57
Project: BaseClient   File: LocalBlockIntercommunication.java   Source Code and License 4 votes vote down vote up
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
{
    throw new UnsupportedOperationException();
}
 
Example 58
Project: CustomWorldGen   File: FMLCommonHandler.java   Source Code and License 4 votes vote down vote up
public void firePlayerLoggedOut(EntityPlayer player)
{
    bus().post(new PlayerEvent.PlayerLoggedOutEvent(player));
}
 
Example 59
Project: HardcoreRevival   File: IHardcoreRevival.java   Source Code and License 4 votes vote down vote up
@Nullable
EntityPlayer getRescueTarget();
 
Example 60
Project: Machines-and-Stuff   File: BlockAccumulator.java   Source Code and License 4 votes vote down vote up
@Override
public Container getServerGuiElement(int id, EntityPlayer player, World world, BlockPos blockPos) {
    return new ContainerAccumulator(player.inventory, (TileEntityAccumulator) world.getTileEntity(blockPos));
}