本文整理汇总了Java中net.minecraft.entity.monster.EntityEndermite.setSpawnedByPlayer方法的典型用法代码示例。如果您正苦于以下问题:Java EntityEndermite.setSpawnedByPlayer方法的具体用法?Java EntityEndermite.setSpawnedByPlayer怎么用?Java EntityEndermite.setSpawnedByPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.monster.EntityEndermite
的用法示例。
在下文中一共展示了EntityEndermite.setSpawnedByPlayer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hurtPlayer
import net.minecraft.entity.monster.EntityEndermite; //导入方法依赖的package包/类
private void hurtPlayer(EntityLivingBase entity) {
if (isStandingOnEnderBlock(entity)) {
return;
}
if (isWearingEnderBoots(entity)) {
damageEnderBoots(entity);
return;
}
entity.fallDistance = 0.0F;
entity.attackEntityFrom(DamageSource.FALL, 4f);
if (entity.world.rand.nextFloat() < 0.005F && entity.world.getGameRules().getBoolean("doMobSpawning")) {
EntityEndermite entityendermite = new EntityEndermite(entity.world);
entityendermite.setSpawnedByPlayer(true);
entityendermite.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
entity.world.spawnEntity(entityendermite);
}
}
示例2: hurtPlayer
import net.minecraft.entity.monster.EntityEndermite; //导入方法依赖的package包/类
private void hurtPlayer(final EntityLivingBase entity, Vec3d transportTo) {
if (Teletory.isWearingEnderBoots(entity)) {
Teletory.damageEnderBoots(entity);
return;
}
entity.fallDistance = 0.0F;
entity.attackEntityFrom(DamageSource.FALL, 4f);
if (entity.world.rand.nextFloat() < 0.05F && entity.world.getGameRules().getBoolean("doMobSpawning")) {
EntityEndermite entityendermite = new EntityEndermite(entity.world);
entityendermite.setSpawnedByPlayer(true);
System.out.println("spawn at " + transportTo.x + " " + transportTo.y + " " + transportTo.z);
entityendermite.setLocationAndAngles(transportTo.x, transportTo.y, transportTo.z, entity.rotationYaw,
entity.rotationPitch);
entity.world.spawnEntity(entityendermite);
}
}
示例3: doTeleport
import net.minecraft.entity.monster.EntityEndermite; //导入方法依赖的package包/类
private static boolean doTeleport(@Nonnull World world, @Nonnull EntityLivingBase entity, double targetX, double targetY, double targetZ) {
float damage = 5f;
if (entity.getMaxHealth() < 10f) {
damage = 1f;
}
EnderTeleportEvent event = new EnderTeleportEvent(entity, targetX, targetY, targetZ, damage);
if (!MinecraftForge.EVENT_BUS.post(event)) {
if (rand.nextFloat() < 0.15F && world.getGameRules().getBoolean("doMobSpawning") && !(entity instanceof EntityEndermite)) {
EntityEndermite entityendermite = new EntityEndermite(world);
entityendermite.setSpawnedByPlayer(true);
entityendermite.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
world.spawnEntity(entityendermite);
}
if (entity.isRiding()) {
entity.dismountRidingEntity();
}
if (entity.isBeingRidden()) {
for (Entity passenger : entity.getPassengers()) {
passenger.dismountRidingEntity();
}
}
if (entity instanceof EntityPlayerMP) {
((EntityPlayerMP) entity).connection.setPlayerLocation(event.getTargetX(), event.getTargetY(), event.getTargetZ(), entity.rotationYaw,
entity.rotationPitch);
} else {
entity.setPositionAndUpdate(event.getTargetX(), event.getTargetY(), event.getTargetZ());
}
entity.fallDistance = 0.0F;
entity.attackEntityFrom(DamageSource.FALL, event.getAttackDamage());
return true;
}
return false;
}
示例4: onImpact
import net.minecraft.entity.monster.EntityEndermite; //导入方法依赖的package包/类
/**
* Called when this EntityThrowable hits a block or entity.
*/
protected void onImpact(MovingObjectPosition p_70184_1_)
{
EntityLivingBase entitylivingbase = this.getThrower();
if (p_70184_1_.entityHit != null)
{
if (p_70184_1_.entityHit == this.field_181555_c)
{
return;
}
p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, entitylivingbase), 0.0F);
}
for (int i = 0; i < 32; ++i)
{
this.worldObj.spawnParticle(EnumParticleTypes.PORTAL, this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian(), new int[0]);
}
if (!this.worldObj.isRemote)
{
if (entitylivingbase instanceof EntityPlayerMP)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)entitylivingbase;
if (entityplayermp.playerNetServerHandler.getNetworkManager().isChannelOpen() && entityplayermp.worldObj == this.worldObj && !entityplayermp.isPlayerSleeping())
{
if (this.rand.nextFloat() < 0.05F && this.worldObj.getGameRules().getBoolean("doMobSpawning"))
{
EntityEndermite entityendermite = new EntityEndermite(this.worldObj);
entityendermite.setSpawnedByPlayer(true);
entityendermite.setLocationAndAngles(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, entitylivingbase.rotationYaw, entitylivingbase.rotationPitch);
this.worldObj.spawnEntityInWorld(entityendermite);
}
if (entitylivingbase.isRiding())
{
entitylivingbase.mountEntity((Entity)null);
}
entitylivingbase.setPositionAndUpdate(this.posX, this.posY, this.posZ);
entitylivingbase.fallDistance = 0.0F;
entitylivingbase.attackEntityFrom(DamageSource.fall, 5.0F);
}
}
else if (entitylivingbase != null)
{
entitylivingbase.setPositionAndUpdate(this.posX, this.posY, this.posZ);
entitylivingbase.fallDistance = 0.0F;
}
this.setDead();
}
}
示例5: onImpact
import net.minecraft.entity.monster.EntityEndermite; //导入方法依赖的package包/类
/**
* Called when this EntityThrowable hits a block or entity.
*/
protected void onImpact(RayTraceResult result)
{
EntityLivingBase entitylivingbase = this.getThrower();
if (result.entityHit != null)
{
if (result.entityHit == this.thrower)
{
return;
}
result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, entitylivingbase), 0.0F);
}
if (result.typeOfHit == RayTraceResult.Type.BLOCK)
{
BlockPos blockpos = result.getBlockPos();
TileEntity tileentity = this.world.getTileEntity(blockpos);
if (tileentity instanceof TileEntityEndGateway)
{
TileEntityEndGateway tileentityendgateway = (TileEntityEndGateway)tileentity;
if (entitylivingbase != null)
{
tileentityendgateway.teleportEntity(entitylivingbase);
this.setDead();
return;
}
tileentityendgateway.teleportEntity(this);
return;
}
}
for (int i = 0; i < 32; ++i)
{
this.world.spawnParticle(EnumParticleTypes.PORTAL, this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian(), new int[0]);
}
if (!this.world.isRemote)
{
if (entitylivingbase instanceof EntityPlayerMP)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)entitylivingbase;
if (entityplayermp.connection.getNetworkManager().isChannelOpen() && entityplayermp.world == this.world && !entityplayermp.isPlayerSleeping())
{
if (this.rand.nextFloat() < 0.05F && this.world.getGameRules().getBoolean("doMobSpawning"))
{
EntityEndermite entityendermite = new EntityEndermite(this.world);
entityendermite.setSpawnedByPlayer(true);
entityendermite.setLocationAndAngles(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, entitylivingbase.rotationYaw, entitylivingbase.rotationPitch);
this.world.spawnEntityInWorld(entityendermite);
}
if (entitylivingbase.isRiding())
{
entitylivingbase.dismountRidingEntity();
}
entitylivingbase.setPositionAndUpdate(this.posX, this.posY, this.posZ);
entitylivingbase.fallDistance = 0.0F;
entitylivingbase.attackEntityFrom(DamageSource.fall, 5.0F);
}
}
else if (entitylivingbase != null)
{
entitylivingbase.setPositionAndUpdate(this.posX, this.posY, this.posZ);
entitylivingbase.fallDistance = 0.0F;
}
this.setDead();
}
}
示例6: onItemRightClick
import net.minecraft.entity.monster.EntityEndermite; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
super.onItemRightClick(worldIn, playerIn, hand);
Random rand = new Random();
ItemStack stack = playerIn.getHeldItem(hand);
stack.shrink(1);
worldIn.playSound(null, playerIn.getPosition(), SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
for (int i = 0; i < 32; ++i) {
worldIn.spawnParticle(EnumParticleTypes.PORTAL, playerIn.posX, playerIn.posY + rand.nextDouble() * 2.0D, playerIn.posZ, rand.nextGaussian(), 0.0D, rand.nextGaussian(), new int[0]);
}
if (!worldIn.isRemote) {
if (!playerIn.isPlayerSleeping()) {
double randX = playerIn.posX, randY = playerIn.posY, randZ = playerIn.posZ;
int maxTries = 4000;
int loopCount = 0;
for(boolean goodPos = false; goodPos == false && loopCount < maxTries;) {
randX = (playerIn.posX + rand.nextInt(20) - 10);
randY = (playerIn.posY + rand.nextInt(20) - 10);
randZ = (playerIn.posZ + rand.nextInt(20) - 10);
BlockPos aPos = new BlockPos(randX, randY, randZ);
BlockPos aPos2 = new BlockPos(randX, randY + 1, randZ);
BlockPos aPos3 = new BlockPos(randX, randY + 2, randZ);
IBlockState block = worldIn.getBlockState(aPos);
IBlockState block2 = worldIn.getBlockState(aPos2);
IBlockState block3 = worldIn.getBlockState(aPos3);
if (loopCount <= (maxTries / 3) * 2) {
if (block.getMaterial().blocksMovement() &&
!block2.getMaterial().blocksMovement() &&
!block3.getMaterial().blocksMovement()){
randY ++;
goodPos = true;
}
} else {
if (!block2.getMaterial().blocksMovement() &&
!block3.getMaterial().blocksMovement())
goodPos = true;
}
loopCount ++;
if (loopCount >= maxTries && goodPos == false) {
randX = playerIn.posX;
randY = playerIn.posY;
randZ = playerIn.posZ;
goodPos = true;
}
}
net.minecraftforge.event.entity.living.EnderTeleportEvent event = new net.minecraftforge.event.entity.living.EnderTeleportEvent(playerIn, randX, randY, randZ, 2.0F);
if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) {
if (rand.nextFloat() < 0.03F && worldIn.getGameRules().getBoolean("doMobSpawning")) {
EntityEndermite entityendermite = new EntityEndermite(worldIn);
entityendermite.setSpawnedByPlayer(true);
entityendermite.setLocationAndAngles(playerIn.posX, playerIn.posY, playerIn.posZ, playerIn.rotationYaw, playerIn.rotationPitch);
worldIn.spawnEntity(entityendermite);
}
if (playerIn.isRiding()) {
playerIn.dismountEntity(playerIn.getRidingEntity());
}
playerIn.setPositionAndUpdate(event.getTargetX(), event.getTargetY(), event.getTargetZ());
playerIn.fallDistance = 0.0F;
playerIn.attackEntityFrom(DamageSource.FALL, event.getAttackDamage());
}
}
}
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}