if(!world.isRemote && pos.entityHit != null && pos.entityHit instanceof EntityLivingBase && pos.entityHit != getThrower()) { EntityLivingBase thrower = getThrower(); pos.entityHit.attackEntityFrom(thrower != null ? thrower instanceof EntityPlayer ? DamageSource.causeThrownDamage(this, thrower) : DamageSource.causeMobDamage(thrower) : DamageSource.GENERIC, 12); if(isFire()) pos.entityHit.setFire(5);
@Override protected void onImpact(RayTraceResult par1MovingObjectPosition) { if (par1MovingObjectPosition.entityHit != null) { par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F); } for (int i = 0; i < 32; ++i) { this.world.spawnParticle(EnumParticleTypes.CRIT_MAGIC, this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian()); } if (!this.world.isRemote) { if (this.getThrower() != null && this.getThrower() instanceof EntityPlayerMP) { EntityHelpers.onEntityCollided(this.world, par1MovingObjectPosition.getBlockPos(), this); this.world.addWeatherEffect(new EntityLightningBolt(this.world, this.posX, this.posY, this.posZ, false)); } this.setDead(); } }
@Override protected void onImpact(MovingObjectPosition mop) { if (!inGround) { for (int l = 0; l < 4; ++l) { worldObj.spawnParticle(EnumParticleTypes.CRIT, posX, posY, posZ, 0.0D, 0.0D, 0.0D); } } if (mop.entityHit != null && !inGround) { mop.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), 2.0F); } else { this.motionX = (double)((float)(mop.hitVec.xCoord - this.posX)); this.motionY = (double)((float)(mop.hitVec.yCoord - this.posY)); this.motionZ = (double)((float)(mop.hitVec.zCoord - this.posZ)); float f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); this.posX -= this.motionX / (double) f2 * 0.05000000074505806D; this.posY -= this.motionY / (double) f2 * 0.05000000074505806D; this.posZ -= this.motionZ / (double) f2 * 0.05000000074505806D; inGround = true; } if (!worldObj.isRemote) { //setDead(); } }
@Override protected void processImpact(RayTraceResult mop) { if (mop.entityHit != null) { float damage = MathHelper.nextFloat(world.rand, DAMAGE_MIN, DAMAGE_MAX); mop.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage); } else { // drop as item UtilItemStack.dropItemStackInWorld(world, mop.getBlockPos(), bullet); } this.setDead(); } }
@Override protected void onImpact(RayTraceResult rayTraceResult) { if (rayTraceResult.entityHit != null) { rayTraceResult.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), 0.0F); } if (!worldObj.isRemote) { NetworkRegistry.TargetPoint target = new NetworkRegistry.TargetPoint(dimension, posX, posY, posZ, 80); NetworkHandler.channel.sendToAllAround(new MessageFX(posX, posY, posZ, MessageFX.FX.PLASTIC_EGG_BREAK), target); setDead(); } } }
@Override protected void onImpact(@Nonnull RayTraceResult impact) { if (NullHelper.untrust(impact.entityHit) != null) { impact.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), 0.0F); } if (!world.isRemote && rand.nextInt(8) == 0) { Entity entitychicken = EntityList.createEntityByIDFromName(new ResourceLocation("enderiozoo", "owl"), world); if (entitychicken instanceof EntityAgeable) { ((EntityAgeable) entitychicken).setGrowingAge(-24000); entitychicken.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0.0F); world.spawnEntity(entitychicken); } else if (thrower instanceof EntityPlayer) { ((EntityPlayer) thrower).sendStatusMessage(Lang.OWL_NO_OWL.toChatServer(), true); } else { Log.warn(Lang.OWL_NO_OWL.toChatServer()); } } for (int i = 0; i < 8; ++i) { world.spawnParticle(EnumParticleTypes.ITEM_CRACK, posX, posY, posZ, (rand.nextFloat() - 0.5D) * 0.08D, (rand.nextFloat() - 0.5D) * 0.08D, (rand.nextFloat() - 0.5D) * 0.08D, new int[] { Item.getIdFromItem(ModObject.item_owl_egg.getItemNN()) }); } if (!world.isRemote) { setDead(); } }
@Override protected void onImpact(RayTraceResult result) { if (result.entityHit == this.getThrower() || this.ticksExisted < 2 || getEntityWorld().isRemote) return; if (result.entityHit instanceof EntityLivingBase) { if (result.entityHit.getEntityWorld().rand.nextDouble() < 0.25) ((EntityLivingBase) result.entityHit).addPotionEffect(new PotionEffect(RegistrarBloodMagic.SOUL_SNARE, 300, 0)); result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float) 0); } for (int j = 0; j < 8; ++j) this.getEntityWorld().spawnParticle(EnumParticleTypes.SNOWBALL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); this.setDead(); } }
/** * Called when this EntityThrowable hits a block or entity. */ protected void onImpact(RayTraceResult result) { if (result.entityHit != null) { result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F); } if (!this.world.isRemote && this.thrower != null) { EntityDeathWorm deathworm = new EntityDeathWorm(this.world); deathworm.setVariant(new Random().nextInt(3)); deathworm.setTamed(true); deathworm.setWormHome(new BlockPos(this)); deathworm.setWormAge(1); deathworm.setDeathWormScale(giant ? (0.25F + (float) (Math.random() * 0.35F)) * 4 : 0.25F + (float) (Math.random() * 0.35F)); deathworm.setOwnerId(this.thrower.getUniqueID()); deathworm.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); this.world.spawnEntity(deathworm); this.world.setEntityState(this, (byte) 3); this.setDead(); } } }
private void onHitEntity(RayTraceResult mop) { EntityLivingBase e = (EntityLivingBase) mop.entityHit; if (e.isBurning()) { e.extinguish(); } e.addPotionEffect(new PotionEffect(PotionEffectRegistry.SNOW, Const.TICKS_PER_SEC * 30)); e.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, Const.TICKS_PER_SEC * 30, SLOWNESSLEVEL)); // do the snowball damage, which should be none. put out the fire mop.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage); }
@Override protected void onImpact(RayTraceResult position) { if(position.typeOfHit == RayTraceResult.Type.ENTITY && !observing && !getEntityWorld().isRemote) { if(position.entityHit != null) { position.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F); } if(getThrower() instanceof EntityPlayerMP && getThrower() != position.entityHit && position.entityHit instanceof EntityLivingBase) { spawnSwarm(this.getThrower(), (EntityLivingBase) position.entityHit); } else { this.setDead(); } } }
@Override protected void onImpact(RayTraceResult mop) { if (!getEntityWorld().isRemote) { if (mop.entityHit != null && mop.entityHit != thrower) { byte byte0 = 6; if (mop.entityHit instanceof EntityWasp) byte0 = 0; if (!mop.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), byte0)) ; if (isBurning() && !(mop.entityHit instanceof EntityEnderman)) mop.entityHit.setFire(5); setDead(); } Erebus.NETWORK_WRAPPER.sendToAll(new PacketParticle(ParticleType.WASP_DAGGER, (float) posX, (float) posY, (float) posZ)); } }
@Override protected void onImpact(RayTraceResult result) { EntityLivingBase thrower = this.getThrower(); if (thrower instanceof DilophosaurusEntity) { DilophosaurusEntity spitter = (DilophosaurusEntity) thrower; if (result.entityHit != null && result.entityHit instanceof EntityLivingBase && result.entityHit != spitter && (result.entityHit == spitter.getAttackTarget() || !(result.entityHit instanceof DilophosaurusEntity))) { EntityLivingBase entityHit = (EntityLivingBase) result.entityHit; entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 4.0F); entityHit.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, 300, 1, false, false)); entityHit.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 300, 1, false, false)); if (!this.world.isRemote) { this.setDead(); } } } }
@Override protected void onImpact(RayTraceResult result) { if(result.entityHit != null) result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), 0.0F); if(!world.isRemote) { EntityParrot parrot = new EntityParrot(world); parrot.setVariant(getColor()); parrot.setGrowingAge(-24000); parrot.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0.0F); world.spawnEntity(parrot); world.setEntityState(this, (byte) 3); setDead(); } }
protected void onImpact(RayTraceResult result) { if (result.entityHit != null) { result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F); } if (!this.world.isRemote) { EntityHippogryph hippogryph = new EntityHippogryph(this.world); hippogryph.setGrowingAge(-24000); hippogryph.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); if (itemstack != null) { hippogryph.setVariant(itemstack.getMetadata()); } this.world.spawnEntity(hippogryph); } this.world.setEntityState(this, (byte) 3); this.setDead(); } }
@Override protected void processImpact(RayTraceResult mop) { if (mop.entityHit != null) { if (isOwner(mop.entityHit)) { //i hit owner, im done dropAsItem(); } else { float damage = MathHelper.nextFloat(world.rand, DAMAGE_MIN, DAMAGE_MAX); mop.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage); if (mop.entityHit instanceof EntityLivingBase) { EntityLivingBase living = (EntityLivingBase) mop.entityHit; if (living.isPotionActive(PotionEffectRegistry.STUN) == false) { living.addPotionEffect(new PotionEffect(PotionEffectRegistry.STUN, STUN_TICKS, 1)); } } } } else { // hit a block or something, go back setIsReturning(); } }
@Override protected void onImpact(RayTraceResult target) { if (target.entityHit != null) { byte damage = 4; if (!target.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), damage)) ; if (isBurning() && !(target.entityHit instanceof EntityEnderman)) target.entityHit.setFire(5); if (!getEntityWorld().isRemote) { target.entityHit.addVelocity(-MathHelper.sin(getThrower().rotationYaw * 3.141593F / 180.0F) * 0.5F, 0.1D, MathHelper.cos(getThrower().rotationYaw * 3.141593F / 180.0F) * 0.5F); spawnWoodlouse(); } } else if (!getEntityWorld().isRemote) spawnWoodlouse(); }
private void attemptRelease(RayTraceResult traceResult) { BlockPos pos = new BlockPos(traceResult.hitVec); if (traceResult.entityHit != null) { pos = traceResult.entityHit.getPosition().add(0, 1, 0); traceResult.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0F); } if (ServerHelper.isServerWorld(world)) { if (traceResult.sideHit != null && getThrower() instanceof EntityPlayer && !((EntityPlayer) getThrower()).canPlayerEdit(pos, traceResult.sideHit, blockCheck)) { ItemMorb.dropMorb(type, entityData, world, pos); this.setDead(); return; } double x = traceResult.hitVec.x; double y = traceResult.hitVec.y; double z = traceResult.hitVec.z; if (traceResult.sideHit != null) { x += traceResult.sideHit.getFrontOffsetX(); z += traceResult.sideHit.getFrontOffsetZ(); } spawnCreature(world, entityData, x, y, z); if (drop && (world.rand.nextInt(100) < ItemMorb.REUSE_CHANCE || type > 0)) { ItemMorb.dropMorb(type, null, world, pos); } this.setDead(); } }
@Override protected void onImpact(RayTraceResult position) { if (position.entityHit != null) { position.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F); } 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()); } if (!this.world.isRemote) { if (this.getThrower() != null && this.getThrower() instanceof EntityPlayerMP) { EntityPlayerMP entityplayermp = (EntityPlayerMP)this.getThrower(); if (entityplayermp.connection.netManager.isChannelOpen() && entityplayermp.world == this.world) { EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ, 0.0F); if (!MinecraftForge.EVENT_BUS.post(event)) { if (this.getThrower().isRiding()) { this.getThrower().dismountRidingEntity(); } this.getThrower().setPositionAndUpdate(event.getTargetX(), event.getTargetY(), event.getTargetZ()); this.getThrower().fallDistance = 0.0F; this.getThrower().attackEntityFrom(DamageSource.FALL, event.getAttackDamage()); this.getThrower().addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, BloodPearlOfTeleportationConfig.slownessDuration * 20, 2)); } } } this.setDead(); } }
@Override protected void processImpact(RayTraceResult mop) { if (mop.entityHit != null) { //zero damage means just knockback mop.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0); } EnumFacing sideHit = mop.sideHit; BlockPos pos = mop.getBlockPos(); BlockPos offset = mop.getBlockPos(); if (sideHit != null) { offset = pos.offset(sideHit); } if (offset == null) { return; } World world = this.getEntityWorld(); boolean isSideSolid = world.isSideSolid(mop.getBlockPos(), sideHit); boolean isValidBlockstate = BlockTorch.FACING.getAllowedValues().contains(sideHit); boolean isValidLocation = world.isAirBlock(offset) || world.getBlockState(offset) == null || world.getBlockState(offset).getBlock() == null || world.getBlockState(offset).getBlock().isReplaceable(world, offset); if (isValidLocation && isValidBlockstate && isSideSolid && world.isRemote == false) { world.setBlockState(offset, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, sideHit)); } else { UtilItemStack.dropItemStackInWorld(world, this.getPosition(), this.fromLauncher ? Item.getItemFromBlock(Blocks.TORCH) : item); } this.setDead(); }
@Override protected void onImpact(RayTraceResult movingObjectPosition) { BlockPos pos = new BlockPos(MathHelper.floor(posX), MathHelper.floor(posY), MathHelper.floor(posZ)); if (movingObjectPosition.entityHit != null) { if (!getEntityWorld().isRemote) if (movingObjectPosition.entityHit instanceof EntityLivingBase) { ((EntityLivingBase) movingObjectPosition.entityHit).addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, 2 * 20, 0)); getEntityWorld().playEvent(null, 2001, pos, Block.getIdFromBlock(Blocks.SAND)); } if (!movingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), (float) (ConfigHandler.INSTANCE.mobAttackDamageMultiplier < 2 ? 4D : 4D * ConfigHandler.INSTANCE.mobAttackDamageMultiplier))) ; } else if (movingObjectPosition.entityHit == null && Blocks.SAND.canPlaceBlockAt(getEntityWorld(), pos)) if (!getEntityWorld().isRemote) { setDead(); getEntityWorld().setBlockState(pos, Blocks.SAND.getDefaultState()); } if (!getEntityWorld().isRemote) { setDead(); } }