/**
* 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;
}
}
java类net.minecraft.entity.player.EntityPlayer的实例源码
EntityEnderman.java 文件源码
项目:BaseClient
阅读 21
收藏 0
点赞 0
评论 0
EntitySheep.java 文件源码
项目:BaseClient
阅读 18
收藏 0
点赞 0
评论 0
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));
}
PacketClassGui.java 文件源码
项目:Loot-Slash-Conquer
阅读 25
收藏 0
点赞 0
评论 0
@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;
}
Motion.java 文件源码
项目:Zombe-Modpack
阅读 20
收藏 0
点赞 0
评论 0
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));
}
}
BlockFarmland.java 文件源码
项目:DecompiledMinecraft
阅读 21
收藏 0
点赞 0
评论 0
/**
* Block's chance to react to a living entity falling on it.
*/
public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fallDistance)
{
if (entityIn instanceof EntityLivingBase)
{
if (!worldIn.isRemote && worldIn.rand.nextFloat() < fallDistance - 0.5F)
{
if (!(entityIn instanceof EntityPlayer) && !worldIn.getGameRules().getBoolean("mobGriefing"))
{
return;
}
worldIn.setBlockState(pos, Blocks.dirt.getDefaultState());
}
super.onFallenUpon(worldIn, pos, entityIn, fallDistance);
}
}
EntitySkeleton.java 文件源码
项目:DecompiledMinecraft
阅读 19
收藏 0
点赞 0
评论 0
/**
* Called when the mob's health reaches 0.
*/
public void onDeath(DamageSource cause)
{
super.onDeath(cause);
if (cause.getSourceOfDamage() instanceof EntityArrow && cause.getEntity() instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)cause.getEntity();
double d0 = entityplayer.posX - this.posX;
double d1 = entityplayer.posZ - this.posZ;
if (d0 * d0 + d1 * d1 >= 2500.0D)
{
entityplayer.triggerAchievement(AchievementList.snipeSkeleton);
}
}
else if (cause.getEntity() instanceof EntityCreeper && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled())
{
((EntityCreeper)cause.getEntity()).func_175493_co();
this.entityDropItem(new ItemStack(Items.skull, 1, this.getSkeletonType() == 1 ? 1 : 0), 0.0F);
}
}
IceFragment.java 文件源码
项目:IceMod
阅读 24
收藏 0
点赞 0
评论 0
/** 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
}
EntitySkeleton.java 文件源码
项目:DecompiledMinecraft
阅读 19
收藏 0
点赞 0
评论 0
public EntitySkeleton(World worldIn)
{
super(worldIn);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIRestrictSun(this));
this.tasks.addTask(3, new EntityAIFleeSun(this, 1.0D));
this.tasks.addTask(3, new EntityAIAvoidEntity(this, EntityWolf.class, 6.0F, 1.0D, 1.2D));
this.tasks.addTask(4, new EntityAIWander(this, 1.0D));
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(6, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0]));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityIronGolem.class, true));
if (worldIn != null && !worldIn.isRemote)
{
this.setCombatTask();
}
}
ContainerHopper.java 文件源码
项目:DecompiledMinecraft
阅读 21
收藏 0
点赞 0
评论 0
public ContainerHopper(InventoryPlayer playerInventory, IInventory hopperInventoryIn, EntityPlayer player)
{
this.hopperInventory = hopperInventoryIn;
hopperInventoryIn.openInventory(player);
int i = 51;
for (int j = 0; j < hopperInventoryIn.getSizeInventory(); ++j)
{
this.addSlotToContainer(new Slot(hopperInventoryIn, j, 44 + j * 18, 20));
}
for (int l = 0; l < 3; ++l)
{
for (int k = 0; k < 9; ++k)
{
this.addSlotToContainer(new Slot(playerInventory, k + l * 9 + 9, 8 + k * 18, l * 18 + i));
}
}
for (int i1 = 0; i1 < 9; ++i1)
{
this.addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 58 + i));
}
}
Track.java 文件源码
项目:Clef
阅读 21
收藏 0
点赞 0
评论 0
@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();
}
}
}
}
DamageDistribution.java 文件源码
项目:FirstAid
阅读 18
收藏 0
点赞 0
评论 0
@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;
}
ItemElytra.java 文件源码
项目:CustomWorldGen
阅读 25
收藏 0
点赞 0
评论 0
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);
}
}
ServerConfigurationManager.java 文件源码
项目:BaseClient
阅读 21
收藏 0
点赞 0
评论 0
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);
}
}
}
}
ItemRemote.java 文件源码
项目:pnc-repressurized
阅读 30
收藏 0
点赞 0
评论 0
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;
}
TileEntityStructure.java 文件源码
项目:Backmemed
阅读 20
收藏 0
点赞 0
评论 0
public boolean usedBy(EntityPlayer player)
{
if (!player.canUseCommandBlock())
{
return false;
}
else
{
if (player.getEntityWorld().isRemote)
{
player.openEditStructure(this);
}
return true;
}
}
EntityArrow.java 文件源码
项目:DecompiledMinecraft
阅读 26
收藏 0
点赞 0
评论 0
/**
* Called by a player entity when they collide with an entity
*/
public void onCollideWithPlayer(EntityPlayer entityIn)
{
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0)
{
boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && entityIn.capabilities.isCreativeMode;
if (this.canBePickedUp == 1 && !entityIn.inventory.addItemStackToInventory(new ItemStack(Items.arrow, 1)))
{
flag = false;
}
if (flag)
{
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
entityIn.onItemPickup(this, 1);
this.setDead();
}
}
}
ItemSlab.java 文件源码
项目:Backmemed
阅读 24
收藏 0
点赞 0
评论 0
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);
}
CommandBlockBaseLogic.java 文件源码
项目:CustomWorldGen
阅读 22
收藏 0
点赞 0
评论 0
public boolean tryOpenEditCommandBlock(EntityPlayer playerIn)
{
if (!playerIn.canUseCommandBlock())
{
return false;
}
else
{
if (playerIn.getEntityWorld().isRemote)
{
playerIn.displayGuiEditCommandCart(this);
}
return true;
}
}
BlockFlowerPot.java 文件源码
项目:BaseClient
阅读 17
收藏 0
点赞 0
评论 0
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);
}
}
}
ItemTooltipEvent.java 文件源码
项目:CustomWorldGen
阅读 45
收藏 0
点赞 0
评论 0
/**
* 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;
}
EntitySheep.java 文件源码
项目:BaseClient
阅读 25
收藏 0
点赞 0
评论 0
/**
* 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);
}
TF2ProjectileHandler.java 文件源码
项目:Mods
阅读 18
收藏 0
点赞 0
评论 0
@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;
}
EntityWolf.java 文件源码
项目:DecompiledMinecraft
阅读 20
收藏 0
点赞 0
评论 0
public EntityWolf(World worldIn)
{
super(worldIn);
this.setSize(0.6F, 0.8F);
((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, this.aiSit);
this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F));
this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true));
this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
this.tasks.addTask(6, new EntityAIMate(this, 1.0D));
this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
this.tasks.addTask(8, new EntityAIBeg(this, 8.0F));
this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(9, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true, new Class[0]));
this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntityAnimal.class, false, new Predicate<Entity>()
{
public boolean apply(Entity p_apply_1_)
{
return p_apply_1_ instanceof EntitySheep || p_apply_1_ instanceof EntityRabbit;
}
}));
this.targetTasks.addTask(5, new EntityAINearestAttackableTarget(this, EntitySkeleton.class, false));
this.setTamed(false);
}
BlockDoublePlant.java 文件源码
项目:CustomWorldGen
阅读 28
收藏 0
点赞 0
评论 0
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;
}
}
GuiContainerCreative.java 文件源码
项目:DecompiledMinecraft
阅读 22
收藏 0
点赞 0
评论 0
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
if (index >= this.inventorySlots.size() - 9 && index < this.inventorySlots.size())
{
Slot slot = (Slot)this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
slot.putStack((ItemStack)null);
}
}
return null;
}
ItemSalt.java 文件源码
项目:Bewitchment
阅读 18
收藏 0
点赞 0
评论 0
@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;
}
}
ServerCommand.java 文件源码
项目:ProgressiveDifficulty
阅读 20
收藏 0
点赞 0
评论 0
private void sendChat(ICommandSender sender, String[] msg){
EntityPlayer player = (EntityPlayer)sender.getCommandSenderEntity();
for (String str : msg)
{
TextComponentString line = new TextComponentString(str);
player.sendMessage(line);
}
}
ItemStack.java 文件源码
项目:DecompiledMinecraft
阅读 23
收藏 0
点赞 0
评论 0
/**
* Called when a Block is destroyed using this ItemStack
*/
public void onBlockDestroyed(World worldIn, Block blockIn, BlockPos pos, EntityPlayer playerIn)
{
boolean flag = this.item.onBlockDestroyed(this, worldIn, blockIn, pos, playerIn);
if (flag)
{
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this.item)]);
}
}
EntityAIFollowOwner.java 文件源码
项目:DecompiledMinecraft
阅读 22
收藏 0
点赞 0
评论 0
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
EntityLivingBase entitylivingbase = this.thePet.getOwner();
if (entitylivingbase == null)
{
return false;
}
else if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer)entitylivingbase).isSpectator())
{
return false;
}
else if (this.thePet.isSitting())
{
return false;
}
else if (this.thePet.getDistanceSqToEntity(entitylivingbase) < (double)(this.minDist * this.minDist))
{
return false;
}
else
{
this.theOwner = entitylivingbase;
return true;
}
}
GuiScreenBook.java 文件源码
项目:DecompiledMinecraft
阅读 26
收藏 0
点赞 0
评论 0
public GuiScreenBook(EntityPlayer player, ItemStack book, boolean isUnsigned)
{
this.editingPlayer = player;
this.bookObj = book;
this.bookIsUnsigned = isUnsigned;
if (book.hasTagCompound())
{
NBTTagCompound nbttagcompound = book.getTagCompound();
this.bookPages = nbttagcompound.getTagList("pages", 8);
if (this.bookPages != null)
{
this.bookPages = (NBTTagList)this.bookPages.copy();
this.bookTotalPages = this.bookPages.tagCount();
if (this.bookTotalPages < 1)
{
this.bookTotalPages = 1;
}
}
}
if (this.bookPages == null && isUnsigned)
{
this.bookPages = new NBTTagList();
this.bookPages.appendTag(new NBTTagString(""));
this.bookTotalPages = 1;
}
}