net.minecraft.entity.EntityLivingBase Java Examples
The following examples show how to use
net.minecraft.entity.EntityLivingBase.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SwitchHeldItemAndRotationPacket.java From Cyberware with MIT License | 6 votes |
public static void faceEntity(Entity player, Entity entityIn) { double d0 = entityIn.posX - player.posX; double d2 = entityIn.posZ - player.posZ; double d1; if (entityIn instanceof EntityLivingBase) { EntityLivingBase entitylivingbase = (EntityLivingBase)entityIn; d1 = entitylivingbase.posY + (double)entitylivingbase.getEyeHeight() - (player.posY + (double)player.getEyeHeight()); } else { d1 = (entityIn.getEntityBoundingBox().minY + entityIn.getEntityBoundingBox().maxY) / 2.0D - (player.posY + (double)player.getEyeHeight()); } double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2); float f = (float)(MathHelper.atan2(d2, d0) * (180D / Math.PI)) - 90.0F; float f1 = (float)(-(MathHelper.atan2(d1, d3) * (180D / Math.PI))); player.rotationPitch = f1; player.rotationYaw = f; }
Example #2
Source File: RenderWaterPad.java From AgriCraft with MIT License | 6 votes |
@Override public void renderInventoryBlock(ITessellator tess, World world, IBlockState state, BlockWaterPad block, ItemStack stack, EntityLivingBase entity, ItemCameraTransforms.TransformType type) { // Icons final TextureAtlasSprite matIcon = BaseIcons.DIRT.getIcon(); final TextureAtlasSprite waterIcon = BaseIcons.WATER_STILL.getIcon(); // Draw Base renderBase(tess, matIcon); // Draw Sides for (EnumFacing dir : EnumFacing.HORIZONTALS) { renderSide(tess, dir, matIcon); } // Full if (AgriProperties.POWERED.getValue(state)) { renderWater(tess, waterIcon); } }
Example #3
Source File: WirelessBolt.java From WirelessRedstone with MIT License | 6 votes |
private void vecBBDamageSegment(Vector3 start, Vector3 end, ArrayList<Entity> entitylist) { Vec3 start3D = start.toVec3D(); Vec3 end3D = end.toVec3D(); for (Iterator<Entity> iterator = entitylist.iterator(); iterator.hasNext(); ) { Entity entity = iterator.next(); if (entity instanceof EntityLivingBase && (entity.boundingBox.isVecInside(start3D) || entity.boundingBox.isVecInside(end3D))) { if (entity instanceof EntityPlayer) entity.attackEntityFrom(WirelessRedstoneCore.damagebolt, playerdamage); else entity.attackEntityFrom(WirelessRedstoneCore.damagebolt, entitydamage); ether.jamEntity((EntityLivingBase) entity, true); } } }
Example #4
Source File: IPotionEffectExplodable.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
default void explode(Entity entityIn) { if (potions.isEmpty()) { potions.add(1); potions.add(3); potions.add(5); potions.add(8); potions.add(11); potions.add(12); potions.add(21); } Random rand = new Random(); int range = 5; List<EntityLivingBase> entities = entityIn.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(entityIn.posX - range, entityIn.posY - range, entityIn.posZ - range, entityIn.posX + range, entityIn.posY + range, entityIn.posZ + range)); for (EntityLivingBase e : entities) e.addPotionEffect(new PotionEffect(Potion.getPotionById(potions.get(rand.nextInt(potions.size()))), rand.nextInt(30) * 20, rand.nextInt(2) + 1)); ClientRunnable.run(new ClientRunnable() { @Override @SideOnly(Side.CLIENT) public void runIfClient() { LibParticles.FIZZING_EXPLOSION(entityIn.world, entityIn.getPositionVector()); } }); }
Example #5
Source File: ModuleEffectLowGravity.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@Override @SuppressWarnings("unused") public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) { Entity targetEntity = spell.getVictim(world); BlockPos targetPos = spell.getTargetPos(); Entity caster = spell.getCaster(world); double potency = spellRing.getAttributeValue(world, AttributeRegistry.POTENCY, spell); double duration = spellRing.getAttributeValue(world, AttributeRegistry.DURATION, spell) * 10; if (!spellRing.taxCaster(world, spell, true)) return false; if (targetEntity != null) { world.playSound(null, targetEntity.getPosition(), ModSounds.TELEPORT, SoundCategory.NEUTRAL, 1, 1); ((EntityLivingBase) targetEntity).addPotionEffect(new PotionEffect(ModPotions.LOW_GRAVITY, (int) duration, (int) potency, true, false)); } return true; }
Example #6
Source File: ItemPetContract.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
private void signContract(ItemStack stack, EntityPlayer oldOwner, EntityLivingBase target) { NBTTagCompound nbt = NBTUtils.getCompoundTag(stack, null, true); UUID uuidOwner = oldOwner.getUniqueID(); nbt.setLong("OwnerM", uuidOwner.getMostSignificantBits()); nbt.setLong("OwnerL", uuidOwner.getLeastSignificantBits()); UUID uuidTarget = target.getUniqueID(); nbt.setLong("OwnableM", uuidTarget.getMostSignificantBits()); nbt.setLong("OwnableL", uuidTarget.getLeastSignificantBits()); nbt.setFloat("Health", target.getHealth()); String str = EntityList.getEntityString(target); if (str != null) { nbt.setString("EntityString", str); } if (target.hasCustomName()) { nbt.setString("CustomName", target.getCustomNameTag()); } oldOwner.getEntityWorld().playSound(null, oldOwner.getPosition(), SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.PLAYERS, 0.5f, 1f); }
Example #7
Source File: ComponentExplosive.java From Artifacts with MIT License | 6 votes |
@Override public boolean itemInteractionForEntity(ItemStack itemStack, EntityPlayer player, EntityLivingBase entityLiving) { if(player.worldObj.isRemote) { PacketBuffer out = new PacketBuffer(Unpooled.buffer()); //System.out.println("Building packet..."); out.writeInt(PacketHandlerServer.EXPLOSIONS); out.writeInt(player.getEntityId()); out.writeInt(player.inventory.currentItem); //out.writeFloat(par3EntityPlayer.getHealth()+1); CToSMessage packet = new CToSMessage(out); //System.out.println("Sending packet..." + player); DragonArtifacts.artifactNetworkWrapper.sendToServer(packet); //par1ItemStack.damageItem(1, par2EntityPlayer); return true; } return false; }
Example #8
Source File: EntityWitherWitch.java From EnderZoo with Creative Commons Zero v1.0 Universal | 6 votes |
protected void manageCats() { if(cats.isEmpty()) { return; } if(noActiveTargetTime > 40) { pacifyCats(); return; } EntityLivingBase currentTarget = getActiveTarget(); EntityLivingBase hitBy = getRevengeTarget(); if(hitBy == null) { //agro the cats if we have been hit or we have actually thrown a potion hitBy = attackedWithPotion; } angerCats(currentTarget, hitBy); }
Example #9
Source File: ItemManometer.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public boolean itemInteractionForEntity(ItemStack iStack, EntityPlayer player, EntityLivingBase entity){ if(!player.worldObj.isRemote) { if(entity instanceof IManoMeasurable) { if(((IPressurizable)iStack.getItem()).getPressure(iStack) > 0F) { List<String> curInfo = new ArrayList<String>(); ((IManoMeasurable)entity).printManometerMessage(player, curInfo); if(curInfo.size() > 0) { ((IPressurizable)iStack.getItem()).addAir(iStack, -30); for(String s : curInfo) { player.addChatComponentMessage(new ChatComponentTranslation(s)); } return true; } } else { player.addChatComponentMessage(new ChatComponentTranslation(EnumChatFormatting.RED + "The Manometer doesn't have any charge!")); } } } return false; }
Example #10
Source File: EntityTofuChinger.java From TofuCraftReload with MIT License | 5 votes |
protected void checkAndPerformAttack(EntityLivingBase p_190102_1_, double p_190102_2_) { double d0 = this.getAttackReachSqr(p_190102_1_); if (p_190102_2_ <= d0 && this.attackTick <= 0) { this.attackTick = 20; this.attacker.attackEntityAsMob(p_190102_1_); EntityTofuChinger.this.setMouseOpen(false); } else if (p_190102_2_ <= d0 * 2.0D) { if (this.attackTick <= 0) { EntityTofuChinger.this.setMouseOpen(false); this.attackTick = 20; } if (this.attackTick <= 10) { EntityTofuChinger.this.setMouseOpen(true); } if (this.attackTick <= 5) { EntityTofuChinger.this.playAttackSound(); } } else { this.attackTick = 20; EntityTofuChinger.this.setMouseOpen(false); } }
Example #11
Source File: InfinitePain.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent public static void onLanding(LivingFallEvent event) { EntityLivingBase elb = event.getEntityLiving(); if(elb.hasItemInSlot(EntityEquipmentSlot.FEET) && elb.getItemStackFromSlot(EntityEquipmentSlot.FEET).getItem() == PAIN_BOOTS) { if(event.getDistance() >= minTriggerHeight) { boolean notObstructed = true; double impactPosition = 0; for(int i = (int) elb.posY + 2; i < elb.world.provider.getHeight(); i++) { BlockPos pos = new BlockPos(elb.posX, i, elb.posZ); IBlockState state = elb.world.getBlockState(pos); if(state.isFullBlock() || state.isFullCube()) { notObstructed = false; impactPosition = i; break; } } if(notObstructed) { elb.setPositionAndUpdate(elb.posX, elb.world.provider.getHeight() + heightToAdd, elb.posZ); event.setDamageMultiplier(0); } else { elb.addVelocity(0, (impactPosition - elb.posY) / 2, 0); elb.attackEntityFrom(DamageSource.GENERIC, damageOnImpact); event.setDamageMultiplier(0); } } } }
Example #12
Source File: ItemPotteryJug.java From TFC2 with GNU General Public License v3.0 | 5 votes |
@Override public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) { if(!worldIn.isRemote) { EntityPlayer player = (EntityPlayer) entityLiving; if(IsWaterJug(stack)) { IFoodStatsTFC food = (IFoodStatsTFC)player.getFoodStats(); food.setWaterLevel(20); TFC.network.sendTo(new CFoodPacket(food), (EntityPlayerMP) player); } if(IsWaterJug(stack) && !((EntityPlayer)entityLiving).capabilities.isCreativeMode) { if(worldIn.rand.nextInt(50) == 0) { stack.shrink(1); entityLiving.playSound(TFC_Sounds.CERAMICBREAK, 0.7f, worldIn.rand.nextFloat() * 0.2f + 0.8f); } else stack.setItemDamage(1); } } return stack; }
Example #13
Source File: RenderAdditionalGolemTH.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
protected int shouldRenderPass(EntityLivingBase entity, int pass, float par3) { if (pass != 0) { return super.shouldRenderPass(entity, pass, par3); } EntityGolemBase golem = (EntityGolemBase) entity; AdditionalGolemCore core = GadomancyApi.getAdditionalGolemCore(golem); if (core != null) { golem.getDataWatcher().getWatchedObject(21).setObject((byte) -1); } int ret = super.shouldRenderPass(entity, pass, par3); //fix for render bug in tc if (RenderGolemHelper.requiresRenderFix((EntityGolemBase) entity)) { RenderGolemHelper.renderCarriedItemsFix(golem); if(toolItem != null) { RenderGolemHelper.renderToolItem(golem, toolItem, mainModel, renderManager); } } if (core != null) { golem.getDataWatcher().getWatchedObject(21).setObject((byte) 1); RenderGolemHelper.renderCore(golem, core); } return ret; }
Example #14
Source File: LaserEvent.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
public LaserHitsBlockEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, int x1, int y1, int z1, int side1, float dropChance1, boolean removeBlock1, boolean dropBlock1) { super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); this.x = x1; this.y = y1; this.z = z1; this.side = side1; this.removeBlock = removeBlock1; this.dropBlock = dropBlock1; this.dropChance = dropChance1; }
Example #15
Source File: ItemBrainUpgrade.java From Cyberware with MIT License | 5 votes |
@SubscribeEvent public void handleTeleJam(EnderTeleportEvent event) { EntityLivingBase te = event.getEntityLiving(); if (CyberwareAPI.isCyberwareInstalled(te, new ItemStack(this, 1, 1))) { event.setCanceled(true); return; } if (te != null) { float range = 25F; List<EntityLivingBase> test = te.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(te.posX - range, te.posY - range, te.posZ - range, te.posX + te.width + range, te.posY + te.height + range, te.posZ + te.width + range)); for (EntityLivingBase e : test) { if (te.getDistanceToEntity(e) <= range) { if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 1))) { event.setCanceled(true); return; } } } } }
Example #16
Source File: EntityMonolithEye.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
protected void redirectArrowAtAttacker(DamageSource source) { if ("arrow".equals(source.getDamageType())) { if (source.getTrueSource() != null && source.getTrueSource() instanceof EntityLivingBase) { attackWithArrow((EntityLivingBase) source.getTrueSource()); } if (source.getImmediateSource() != null) { source.getImmediateSource().setDead(); } } }
Example #17
Source File: ItemFakeHaloBauble.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onWornTick(@Nonnull ItemStack stack, @Nonnull EntityLivingBase player) { if (player.world.isRemote) return; try (ManaManager.CapManagerBuilder mgr = ManaManager.forObject(player)) { mgr.setMaxMana(ConfigValues.crudeHaloBufferSize); mgr.setMaxBurnout(ConfigValues.crudeHaloBufferSize); mgr.removeBurnout(mgr.getMaxBurnout() * ConfigValues.haloGenSpeed * 2); } }
Example #18
Source File: TileInfusionClaw.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
public TileInfusionClaw() { if(Gadomancy.proxy.getSide() == Side.CLIENT) { animationStates = new float[12]; EntityLivingBase entity = Minecraft.getMinecraft().renderViewEntity; lastRenderTick = entity == null ? 0 : entity.ticksExisted; } }
Example #19
Source File: BlockBaseContainer.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) { int facing = MathHelper.floor_double(entity.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; TileEntityEMT tile = (TileEntityEMT) world.getTileEntity(x, y, z); if (facing == 0) tile.facing = 2; else if (facing == 1) tile.facing = 5; else if (facing == 2) tile.facing = 3; else if (facing == 3) tile.facing = 4; }
Example #20
Source File: TileEntitySentryTurret.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void onDescUpdate(){ super.onDescUpdate(); Entity entity = worldObj.getEntityByID(targetEntityId); if(entity instanceof EntityLivingBase) { getMinigun().setAttackTarget((EntityLivingBase)entity); } else { getMinigun().setAttackTarget(null); } }
Example #21
Source File: ItemPetContract.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void addItemOverrides() { this.addPropertyOverride(new ResourceLocation(Reference.MOD_ID, "signed"), new IItemPropertyGetter() { @Override public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn) { return ItemPetContract.this.isSigned(stack) ? 1.0F : 0.0F; } }); }
Example #22
Source File: MixinBlockAnvil.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
@Inject(method = "onBlockPlaced", cancellable = true, at = @At("HEAD")) private void injectAnvilCrashFix(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, CallbackInfoReturnable<IBlockState> cir) { if (((meta >> 2) & ~0x3) != 0) { cir.setReturnValue(super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(BlockAnvil.FACING, placer.getHorizontalFacing().rotateY()).withProperty(BlockAnvil.DAMAGE, 2)); cir.cancel(); } }
Example #23
Source File: BlockAirCannon.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack){ super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLiving, par6ItemStack); TileEntity te = par1World.getTileEntity(par2, par3, par4); if(te instanceof TileEntityAirCannon) { TileEntityAirCannon teAc = (TileEntityAirCannon)te; teAc.onNeighbourBlockChange(par2, par3, par4, this); } }
Example #24
Source File: MixinRendererLivingEntity.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
@Inject(method = "doRender", at = @At("HEAD")) private <T extends EntityLivingBase> void injectChamsPre(T entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo callbackInfo) { final Chams chams = (Chams) LiquidBounce.moduleManager.getModule(Chams.class); if (chams.getState() && chams.getTargetsValue().get() && EntityUtils.isSelected(entity, false)) { GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); GL11.glPolygonOffset(1.0F, -1000000F); } }
Example #25
Source File: MixinEnchantmentHelper.java From VanillaFix with MIT License | 5 votes |
/** @reason Fix memory leak. See mixin class comment. */ @Overwrite public static void applyThornEnchantments(EntityLivingBase user, Entity attacker) { EnchantmentHelper.HurtIterator enchantmentIteratorHurt = new EnchantmentHelper.HurtIterator(); enchantmentIteratorHurt.attacker = attacker; enchantmentIteratorHurt.user = user; if (user != null) { applyEnchantmentModifierArray(enchantmentIteratorHurt, user.getEquipmentAndArmor()); } if (attacker instanceof EntityPlayer) { applyEnchantmentModifier(enchantmentIteratorHurt, user.getHeldItemMainhand()); } }
Example #26
Source File: ItemMaterials.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { super.onUpdate(stack, world, entity, par4, par5); if ((!entity.worldObj.isRemote) && ((stack.getItemDamage() == 14)) && ((entity instanceof EntityLivingBase)) && (!((EntityLivingBase) entity).isEntityUndead()) && (!((EntityLivingBase) entity).isPotionActive(Config.potionTaintPoisonID)) && (world.rand.nextInt(4321) <= stack.stackSize)) { ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Config.potionTaintPoisonID, 120, 0, false)); if ((entity instanceof EntityPlayer)) { InventoryUtils.consumeInventoryItem((EntityPlayer) entity, stack.getItem(), stack.getItemDamage()); } } }
Example #27
Source File: BlockLogVertical.java From TFC2 with GNU General Public License v3.0 | 5 votes |
/******************************************************************************* * 1. Content *******************************************************************************/ @Override public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { if(facing == EnumFacing.DOWN || facing == EnumFacing.UP) return this.getStateFromMeta(meta); else { if(facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH) { if(meta < 8) { return TFCBlocks.LogHorizontal.getStateFromMeta(meta).withProperty(BlockLogHorizontal.ROT_PROPERTY, 1); } else { return TFCBlocks.LogHorizontal2.getStateFromMeta(meta).withProperty(BlockLogHorizontal.ROT_PROPERTY, 1); } } else { if(meta < 8) { return TFCBlocks.LogHorizontal.getStateFromMeta(meta).withProperty(BlockLogHorizontal.ROT_PROPERTY, 0); } else { return TFCBlocks.LogHorizontal2.getStateFromMeta(meta).withProperty(BlockLogHorizontal.ROT_PROPERTY, 0); } } } }
Example #28
Source File: EventHandlerRedirect.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
public static int getFortuneLevel(EntityLivingBase entity) { int fortuneLevel = getRealEnchantmentLevel(Enchantment.fortune.effectId, entity.getHeldItem()); if(entity.isPotionActive(RegisteredPotions.POTION_LUCK)) { int lvl = entity.getActivePotionEffect(RegisteredPotions.POTION_LUCK).getAmplifier() + 1; //Amplifier 0-indexed fortuneLevel += lvl; } return fortuneLevel; }
Example #29
Source File: JetpackPotato.java From SimplyJetpacks with MIT License | 5 votes |
protected void decrementTimer(ItemStack itemStack, EntityLivingBase user) { int timer = NBTHelper.getNBT(itemStack).getInteger(TAG_ROCKET_TIMER); timer = timer > 0 ? timer - 1 : 0; NBTHelper.getNBT(itemStack).setInteger(TAG_ROCKET_TIMER, timer); if (timer == 0) { this.setFired(itemStack); user.worldObj.playSoundAtEntity(user, SimplyJetpacks.RESOURCE_PREFIX + "rocket", 1.0F, 1.0F); } }
Example #30
Source File: BlockStairsTFC.java From TFC2 with GNU General Public License v3.0 | 5 votes |
@Override public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { IBlockState iblockstate = super.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer, hand); iblockstate = iblockstate.withProperty(BlockStairs.FACING, placer.getHorizontalFacing()).withProperty(BlockStairs.SHAPE, EnumShape.STRAIGHT); return (facing != EnumFacing.DOWN) && ((facing == EnumFacing.UP) || (hitY <= 0.5D)) ? iblockstate.withProperty(BlockStairs.HALF, EnumHalf.BOTTOM) : iblockstate.withProperty(BlockStairs.HALF, EnumHalf.TOP); }