/** * Notifies the merchant of a possible merchantrecipe being fulfilled or not. Usually, this is just a sound byte * being played depending if the suggested itemstack is not null. */ public void verifySellingItem(ItemStack stack) { if (!this.worldObj.isRemote && this.livingSoundTime > -this.getTalkInterval() + 20) { this.livingSoundTime = -this.getTalkInterval(); if (stack != null) { this.playSound(SoundEvents.ENTITY_VILLAGER_YES, this.getSoundVolume(), this.getSoundPitch()); } else { this.playSound(SoundEvents.ENTITY_VILLAGER_NO, this.getSoundVolume(), this.getSoundPitch()); } } }
public boolean processInteract(EntityPlayer player, EnumHand hand) { ItemStack itemstack = player.getHeldItem(hand); if (itemstack.getItem() == Items.BUCKET && !player.capabilities.isCreativeMode && !this.isChild()) { player.playSound(SoundEvents.ENTITY_COW_MILK, 1.0F, 1.0F); itemstack.func_190918_g(1); if (itemstack.func_190926_b()) { player.setHeldItem(hand, new ItemStack(Items.MILK_BUCKET)); } else if (!player.inventory.addItemStackToInventory(new ItemStack(Items.MILK_BUCKET))) { player.dropItem(new ItemStack(Items.MILK_BUCKET), false); } return true; } else { return super.processInteract(player, hand); } }
public boolean recipeDropLogic(ItemStack dropped) { if (mode == Mode.NORMAL && changeMode(dropped.getItem())) { play(SoundEvents.ENTITY_FIREWORK_TWINKLE, 0.2F, 1F); dropped.setCount(0); return true; } switch (mode) { case NORMAL: return processingLogic(dropped) || (inv.hasFluid(FluidRegistry.WATER) && acceptIngredient(dropped)); case POTION: return acceptIngredient(dropped); case CUSTOM: return acceptIngredient(dropped); default: } return false; }
/** Fixed vanilla code */ private void damageShield(EntityPlayer owner, float damage) { int i = 1 + MathHelper.floor(damage); owner.getActiveItemStack().damageItem(i, owner); if (owner.getActiveItemStack().getCount() <= 0) { EnumHand enumhand = owner.getActiveHand(); ForgeEventFactory.onPlayerDestroyItem(owner, owner.getActiveItemStack(), enumhand); if(enumhand == EnumHand.MAIN_HAND) { owner.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY); } else { owner.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.EMPTY); } owner.resetActiveHand(); owner.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + owner.world.rand.nextFloat() * 0.4F); } }
/** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } else if (!source.isExplosion() && this.getDisplayedItem() != null) { if (!this.worldObj.isRemote) { this.dropItemOrSelf(source.getEntity(), false); this.playSound(SoundEvents.ENTITY_ITEMFRAME_REMOVE_ITEM, 1.0F, 1.0F); this.setDisplayedItem((ItemStack)null); } return true; } else { return super.attackEntityFrom(source, amount); } }
public void openInventory(EntityPlayer player) { if (!player.isSpectator()) { if (this.field_190598_h < 0) { this.field_190598_h = 0; } ++this.field_190598_h; this.world.addBlockEvent(this.pos, this.getBlockType(), 1, this.field_190598_h); if (this.field_190598_h == 1) { this.world.playSound((EntityPlayer)null, this.pos, SoundEvents.field_191262_fB, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F); } } }
/** * Called by InventoryBasic.onInventoryChanged() on a array that is never filled. */ public void onInventoryChanged(InventoryBasic invBasic) { HorseArmorType horsearmortype = this.getHorseArmorType(); boolean flag = this.isHorseSaddled(); this.updateHorseSlots(); if (this.ticksExisted > 20) { if (horsearmortype == HorseArmorType.NONE && horsearmortype != this.getHorseArmorType()) { this.playSound(SoundEvents.ENTITY_HORSE_ARMOR, 0.5F, 1.0F); } else if (horsearmortype != this.getHorseArmorType()) { this.playSound(SoundEvents.ENTITY_HORSE_ARMOR, 0.5F, 1.0F); } if (!flag && this.isHorseSaddled()) { this.playSound(SoundEvents.ENTITY_HORSE_SADDLE, 0.5F, 1.0F); } } }
public void handleCollectItem(SPacketCollectItem packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); Entity entity = this.clientWorldController.getEntityByID(packetIn.getCollectedItemEntityID()); EntityLivingBase entitylivingbase = (EntityLivingBase)this.clientWorldController.getEntityByID(packetIn.getEntityID()); if (entitylivingbase == null) { entitylivingbase = this.gameController.thePlayer; } if (entity != null) { if (entity instanceof EntityXPOrb) { this.clientWorldController.playSound(entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 0.2F, ((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F, false); } else { this.clientWorldController.playSound(entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F, false); } this.gameController.effectRenderer.addEffect(new ParticleItemPickup(this.clientWorldController, entity, entitylivingbase, 0.5F)); this.clientWorldController.removeEntityFromWorld(packetIn.getCollectedItemEntityID()); } }
/** * Applies or removes armor modifier */ public void updateArmorModifier(int p_184691_1_) { if (!this.world.isRemote) { this.getEntityAttribute(SharedMonsterAttributes.ARMOR).removeModifier(COVERED_ARMOR_BONUS_MODIFIER); if (p_184691_1_ == 0) { this.getEntityAttribute(SharedMonsterAttributes.ARMOR).applyModifier(COVERED_ARMOR_BONUS_MODIFIER); this.playSound(SoundEvents.ENTITY_SHULKER_CLOSE, 1.0F, 1.0F); } else { this.playSound(SoundEvents.ENTITY_SHULKER_OPEN, 1.0F, 1.0F); } } this.dataManager.set(PEEK_TICK, Byte.valueOf((byte)p_184691_1_)); }
/** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ public void onLivingUpdate() { if (!this.onGround && this.motionY < 0.0D) { this.motionY *= 0.6D; } if (this.worldObj.isRemote) { if (this.rand.nextInt(24) == 0 && !this.isSilent()) { this.worldObj.playSound(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, SoundEvents.ENTITY_BLAZE_BURN, this.getSoundCategory(), 1.0F + this.rand.nextFloat(), this.rand.nextFloat() * 0.7F + 0.3F, false); } for (int i = 0; i < 2; ++i) { this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0D, 0.0D, 0.0D, new int[0]); } } super.onLivingUpdate(); }
protected void damageShield(float damage) { if (damage >= 3.0F && this.activeItemStack.getItem() == Items.SHIELD) { int i = 1 + MathHelper.floor(damage); this.activeItemStack.damageItem(i, this); if (this.activeItemStack.func_190926_b()) { EnumHand enumhand = this.getActiveHand(); if (enumhand == EnumHand.MAIN_HAND) { this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.field_190927_a); } else { this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.field_190927_a); } this.activeItemStack = ItemStack.field_190927_a; this.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + this.world.rand.nextFloat() * 0.4F); } } }
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn) { ItemStack itemstack = worldIn.getHeldItem(playerIn); ItemStack itemstack1 = worldIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1); itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_SPLASH_POTION_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!itemStackIn.isRemote) { EntityPotion entitypotion = new EntityPotion(itemStackIn, worldIn, itemstack1); entitypotion.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, -20.0F, 0.5F, 1.0F); itemStackIn.spawnEntityInWorld(entitypotion); } worldIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult(EnumActionResult.SUCCESS, itemstack); }
/** * Save schematic * @param world Target world * @param name Structure name * @param posX X starting position * @param posY Y starting position * @param posZ Z starting position * @param width X axis size * @param height Y axis size * @param length Z axis size * @return Execution status */ private static String cmdSave(UWorld world, String name, int posX, int posY, int posZ, int width, int height, int length) { Report report = new Report() .post("WORLD FRAGMENT", name) .post("POS", "[X=" + posX + ";Y=" + posY + ";Z=" + posZ + "]") .post("SIZE", "[W=" + width + ";H=" + height + ";L=" + length + "]"); try { Blueprint blueprint = new Blueprint(world, new UBlockPos(posX, posY, posZ), new Volume(width, height, length)); File file = new File(Configurator.getSchematicsSavesFolder(), name + ".schematic"); blueprint.saveSchematic(file); Structures.load(file); report.post("SAVED", file.getPath()); } catch (IOException ioe) { report.post("NOT SAVED", ioe.getMessage()); } report.print(); world.sound(new UBlockPos(posX, posY, posZ), SoundEvents.BLOCK_ENDERCHEST_CLOSE, SoundCategory.BLOCKS, 0.5f); return report.toString(); }
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY) { if (worldIn.isRemote) { return true; } else { state = state.cycleProperty(POWERED); worldIn.setBlockState(pos, state, 3); float f = ((Boolean)state.getValue(POWERED)).booleanValue() ? 0.6F : 0.5F; worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.3F, f); worldIn.notifyNeighborsOfStateChange(pos, this, false); EnumFacing enumfacing = ((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing(); worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing.getOpposite()), this, false); return true; } }
public void litCandle() { world.playSound(null, getPos(), SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1F, 1F); this.lit = true; world.profiler.startSection("checkLight"); world.checkLight(pos); world.profiler.endSection(); }
/** * Undo all session history * All projections applied insecure to restore data 1:1 * @return Command execution status */ private static String cmdUndo() { if (undo.isEmpty()) { return "§4No undo data"; } for (Projection projection : undo) { projection.project(true).print(); Posture pst = projection.getPosture(); projection.getWorld().sound(new UBlockPos(pst.getPosX(), pst.getPosY(), pst.getPosZ()), SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.HOSTILE, 1.0f); } undo.clear(); return "§2Undo done"; }
@Override public void update() { if (!world.isRemote && ticks % 2 == 0) { double x = getPos().getX(); double y = getPos().getY(); double z = getPos().getZ(); AxisAlignedBB box = new AxisAlignedBB(x, y, z, x + 1, y + 0.65D, z + 1); final List<EntityItem> entityItemList = world.getEntitiesWithinAABB(EntityItem.class, box); entityItemList.forEach(this::collideItem); } if (inv.hasFluid()) { if (!inv.hasFluid(FluidRegistry.LAVA)) { if (isBoiling()) { handleParticles(); if (ticks % 5 == 0 && world.rand.nextInt(15) == 0) { play(SoundEvents.BLOCK_LAVA_AMBIENT, 0.1F, 1F); } } } else if (ticks % 5 == 0 && world.rand.nextInt(20) == 0) { play(SoundEvents.BLOCK_LAVA_AMBIENT, 1F, 1F); } } if (ticks % 20 == 0) { handleHeat(); tryTurnLiquid(); } if (!world.isRemote && mode == Mode.RITUAL && ritual != null) { handleRitual(); } ++ticks; }
/** * Called by a player entity when they collide with an entity */ public void onCollideWithPlayer(EntityPlayer entityIn) { if (!this.worldObj.isRemote) { if (this.delayBeforeCanPickup == 0 && entityIn.xpCooldown == 0) { if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerPickupXpEvent(entityIn, this))) return; entityIn.xpCooldown = 2; this.worldObj.playSound((EntityPlayer)null, entityIn.posX, entityIn.posY, entityIn.posZ, SoundEvents.ENTITY_EXPERIENCE_ORB_TOUCH, SoundCategory.PLAYERS, 0.1F, 0.5F * ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.8F)); entityIn.onItemPickup(this, 1); ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantments.MENDING, entityIn); if (itemstack != null && itemstack.isItemDamaged()) { int i = Math.min(this.xpToDurability(this.xpValue), itemstack.getItemDamage()); this.xpValue -= this.durabilityToXp(i); itemstack.setItemDamage(itemstack.getItemDamage() - i); } if (this.xpValue > 0) { entityIn.addExperience(this.xpValue); } this.setDead(); } } }
public void playEndermanSound() { if (this.ticksExisted >= this.lastCreepySound + 400) { this.lastCreepySound = this.ticksExisted; if (!this.isSilent()) { this.world.playSound(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ, SoundEvents.ENTITY_ENDERMEN_STARE, this.getSoundCategory(), 2.5F, 1.0F, false); } } }
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) { ItemStack itemstack = playerIn.getHeldItem(hand); ItemStack copy = playerIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1); playerIn.playSound(SoundEvents.ENTITY_SPLASH_POTION_THROW, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!worldIn.isRemote) { EntityBrew brew = new EntityBrew(worldIn, playerIn, copy, EntityBrew.BrewDispersion.SPLASH); brew.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.5F, 1.0F); worldIn.spawnEntity(brew); } return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand)); }
private void dropContents() { this.worldObj.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_ARMORSTAND_BREAK, this.getSoundCategory(), 1.0F, 1.0F); for (int i = 0; i < this.handItems.length; ++i) { if (this.handItems[i] != null && this.handItems[i].stackSize > 0) { if (this.handItems[i] != null) { Block.spawnAsEntity(this.worldObj, (new BlockPos(this)).up(), this.handItems[i]); } this.handItems[i] = null; } } for (int j = 0; j < this.armorItems.length; ++j) { if (this.armorItems[j] != null && this.armorItems[j].stackSize > 0) { if (this.armorItems[j] != null) { Block.spawnAsEntity(this.worldObj, (new BlockPos(this)).up(), this.armorItems[j]); } this.armorItems[j] = null; } } }
@Override public void onCollideWithPlayer(EntityPlayer player) { if (!this.world.isRemote && this.thrower == player && this.inGround && this.throwableShake <= 0) { this.playSound(SoundEvents.ENTITY_ITEM_PICKUP, 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); player.onItemPickup(this, 1); this.setDead(); } }
/** * Called when a Block is right-clicked with this Item */ public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return EnumActionResult.SUCCESS; } else { pos = pos.offset(facing); if (!playerIn.canPlayerEdit(pos, facing, stack)) { return EnumActionResult.FAIL; } else { if (worldIn.getBlockState(pos).getMaterial() == Material.AIR) { worldIn.playSound((EntityPlayer)null, pos, SoundEvents.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 1.0F, (itemRand.nextFloat() - itemRand.nextFloat()) * 0.2F + 1.0F); worldIn.setBlockState(pos, Blocks.FIRE.getDefaultState()); } if (!playerIn.capabilities.isCreativeMode) { --stack.stackSize; } return EnumActionResult.SUCCESS; } } }
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn) { ItemStack itemstack = worldIn.getHeldItem(playerIn); RayTraceResult raytraceresult = this.rayTrace(itemStackIn, worldIn, false); if (raytraceresult != null && raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK && itemStackIn.getBlockState(raytraceresult.getBlockPos()).getBlock() == Blocks.END_PORTAL_FRAME) { return new ActionResult(EnumActionResult.PASS, itemstack); } else { worldIn.setActiveHand(playerIn); if (!itemStackIn.isRemote) { BlockPos blockpos = ((WorldServer)itemStackIn).getChunkProvider().getStrongholdGen(itemStackIn, "Stronghold", new BlockPos(worldIn), false); if (blockpos != null) { EntityEnderEye entityendereye = new EntityEnderEye(itemStackIn, worldIn.posX, worldIn.posY + (double)(worldIn.height / 2.0F), worldIn.posZ); entityendereye.moveTowards(blockpos); itemStackIn.spawnEntityInWorld(entityendereye); itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_ENDEREYE_LAUNCH, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); itemStackIn.playEvent((EntityPlayer)null, 1003, new BlockPos(worldIn), 0); if (!worldIn.capabilities.isCreativeMode) { itemstack.func_190918_g(1); } worldIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult(EnumActionResult.SUCCESS, itemstack); } } return new ActionResult(EnumActionResult.SUCCESS, itemstack); } }
public MovingSoundMinecart(EntityMinecart minecartIn) { super(SoundEvents.ENTITY_MINECART_RIDING, SoundCategory.NEUTRAL); this.minecart = minecartIn; this.repeat = true; this.repeatDelay = 0; }
/** * Ignites this TNT cart. */ public void ignite() { this.minecartTNTFuse = 80; if (!this.world.isRemote) { this.world.setEntityState(this, (byte)10); if (!this.isSilent()) { this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); } } }
@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); }
void damageShield(EntityLivingBase attacked, EntityLivingBase attacker, float f) { ItemStack shield = null; if(Prep1_11.isValid(attacked.getHeldItemOffhand()) && attacked.getHeldItemOffhand().getItem() == RegisterItems.wickerShield) shield = attacked.getHeldItemOffhand(); else if(Prep1_11.isValid(attacked.getHeldItemMainhand()) && attacked.getHeldItemMainhand().getItem() == RegisterItems.wickerShield) shield = attacked.getHeldItemMainhand(); //Copied from EntityPlayer#damageShield() START if(Prep1_11.isEmpty(shield)) return; shield.damageItem(1 + MathHelper.floor(f), attacker); if (shield.getCount() <= 0) { EnumHand enumhand = attacked.getActiveHand(); if(attacked instanceof EntityPlayer) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem((EntityPlayer) attacked, attacked.getActiveItemStack(), enumhand); if (enumhand == EnumHand.MAIN_HAND) { attacked.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY); } else { attacked.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.EMPTY); } attacked.resetActiveHand(); attacked.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + attacked.world.rand.nextFloat() * 0.4F); } //Copied from EntityPlayer#damageShield() END }
private void throwTracker(WorldClient world, EntityPlayer player, int entityID, int throwerID, int freq) { Entity thrower = world.getEntityByID(throwerID); if (throwerID == player.getEntityId()) thrower = player; if (thrower != null && thrower instanceof EntityLiving) { EntityWirelessTracker tracker = new EntityWirelessTracker(world, 0, (EntityLiving) thrower); tracker.setEntityId(entityID); world.addEntityToWorld(entityID, tracker); world.playSound(null, thrower.posX, thrower.posY, thrower.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); } }
public void throwREP(ItemStack itemstack, World world, EntityPlayer player) { if (REPThrowTimeout > 0) { return; } if (!player.capabilities.isCreativeMode) { itemstack.shrink(1); } world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); activeREP = new EntityREP(world, player); world.spawnEntity(activeREP); REPThrowTimeout = 40; }
/** * Attack the specified entity using a ranged attack. * * @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0 */ public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) { if (!this.isDrinkingPotion()) { double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D; double d1 = target.posX + target.motionX - this.posX; double d2 = d0 - this.posY; double d3 = target.posZ + target.motionZ - this.posZ; float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3); PotionType potiontype = PotionTypes.HARMING; if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS)) { potiontype = PotionTypes.SLOWNESS; } else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON)) { potiontype = PotionTypes.POISON; } else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F) { potiontype = PotionTypes.WEAKNESS; } EntityPotion entitypotion = new EntityPotion(this.worldObj, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype)); entitypotion.rotationPitch -= -20.0F; entitypotion.setThrowableHeading(d1, d2 + (double)(f * 0.2F), d3, 0.75F, 8.0F); this.worldObj.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F); this.worldObj.spawnEntityInWorld(entitypotion); } }
private void eatingHorse() { this.openHorseMouth(); if (!this.isSilent()) { this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_HORSE_EAT, this.getSoundCategory(), 1.0F, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F); } }
@Override @SideOnly(Side.CLIENT) @SuppressWarnings("incomplete-switch") public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { if (stateIn.getValue(BURNING)) { EnumFacing enumfacing = stateIn.getValue(FACING); double d0 = pos.getX() + 0.5D; double d1 = pos.getY() + rand.nextDouble() * 6.0D / 16.0D; double d2 = pos.getZ() + 0.5D; double d3 = 0.52D; double d4 = rand.nextDouble() * 0.6D - 0.3D; if (rand.nextDouble() < 0.1D) worldIn.playSound(pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false); switch (enumfacing) { case WEST: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 - 0.52D, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]); worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 - 0.52D, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]); break; case EAST: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + 0.52D, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]); worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + 0.52D, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]); break; case NORTH: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 - 0.52D, 0.0D, 0.0D, 0.0D, new int[0]); worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 - 0.52D, 0.0D, 0.0D, 0.0D, new int[0]); break; case SOUTH: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 + 0.52D, 0.0D, 0.0D, 0.0D, new int[0]); worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 + 0.52D, 0.0D, 0.0D, 0.0D, new int[0]); } } }
/** * Revival zombie curse - fill the player's inventory with poisionous potatoes */ private void performRevivalCurse() { EntityPlayer player = (EntityPlayer)this.victim; ItemStack stack = new ItemStack(Items.POISONOUS_POTATO, 16 + this.rand.nextInt(17), 0); EntityItem entityItem = new EntityItem(this.world, this.posX, this.posY, this.posZ, stack); if (player.inventory.addItemStackToInventory(stack)) { ForgeEventFactory.onItemPickup(entityItem, player); player.playSound(SoundEvents.ENTITY_ZOMBIE_INFECT, 0.75F, (this.rand.nextFloat() * 0.2F) + 0.9F); } }
@SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { if (rand.nextInt(100) == 0) { worldIn.playSound((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, SoundEvents.BLOCK_PORTAL_AMBIENT, SoundCategory.BLOCKS, 0.5F, rand.nextFloat() * 0.4F + 0.8F, false); } for (int i = 0; i < 4; ++i) { double d0 = (double)((float)pos.getX() + rand.nextFloat()); double d1 = (double)((float)pos.getY() + rand.nextFloat()); double d2 = (double)((float)pos.getZ() + rand.nextFloat()); double d3 = ((double)rand.nextFloat() - 0.5D) * 0.5D; double d4 = ((double)rand.nextFloat() - 0.5D) * 0.5D; double d5 = ((double)rand.nextFloat() - 0.5D) * 0.5D; int j = rand.nextInt(2) * 2 - 1; if (worldIn.getBlockState(pos.west()).getBlock() != this && worldIn.getBlockState(pos.east()).getBlock() != this) { d0 = (double)pos.getX() + 0.5D + 0.25D * (double)j; d3 = (double)(rand.nextFloat() * 2.0F * (float)j); } else { d2 = (double)pos.getZ() + 0.5D + 0.25D * (double)j; d5 = (double)(rand.nextFloat() * 2.0F * (float)j); } worldIn.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5, new int[0]); } }
protected void playClickOffSound(World worldIn, BlockPos pos) { if (this.blockMaterial == Material.WOOD) { worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_WOOD_PRESSPLATE_CLICK_OFF, SoundCategory.BLOCKS, 0.3F, 0.7F); } else { worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_STONE_PRESSPLATE_CLICK_OFF, SoundCategory.BLOCKS, 0.3F, 0.5F); } }
public MovingSoundMinecartRiding(EntityPlayer playerRiding, EntityMinecart minecart) { super(SoundEvents.ENTITY_MINECART_INSIDE, SoundCategory.NEUTRAL); this.player = playerRiding; this.minecart = minecart; this.attenuationType = ISound.AttenuationType.NONE; this.repeat = true; this.repeatDelay = 0; }
@Override public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { double x = player.posX; double y = player.posY; double z = player.posZ; String list = player.world.getLoadedEntityList().toString(); boolean spawnOinkBacon = true; boolean spawnOinkSausage = true; spawnOinkBacon = !list.contains("OinkBacon"); spawnOinkSausage = !list.contains("OinkSausage"); if(!worldIn.isRemote) { if(spawnOinkBacon) { spawnBacon(worldIn, pos); }else if(spawnOinkSausage){ spawnSausage(worldIn, pos); }else { chatMessage(player); } }else{ if(spawnOinkBacon) { player.world.playSound(player, x, y, z, SoundEvents.ENTITY_PIG_AMBIENT, SoundCategory.NEUTRAL, 30.0F, 1.0F); }else if(spawnOinkSausage){ player.world.playSound(player, x, y, z, SoundEvents.ENTITY_PIG_AMBIENT, SoundCategory.NEUTRAL, 30.0F, 1.0F); }else { player.world.playSound(player, x, y, z, SoundEvents.ENTITY_PIG_HURT, SoundCategory.NEUTRAL, 30.0F, 1.0F); } } return EnumActionResult.SUCCESS; }
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, false); if (raytraceresult != null && raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK && worldIn.getBlockState(raytraceresult.getBlockPos()).getBlock() == Blocks.END_PORTAL_FRAME) { return new ActionResult(EnumActionResult.PASS, itemStackIn); } else { if (!worldIn.isRemote) { BlockPos blockpos = ((WorldServer)worldIn).getChunkProvider().getStrongholdGen(worldIn, "Stronghold", new BlockPos(playerIn)); if (blockpos != null) { EntityEnderEye entityendereye = new EntityEnderEye(worldIn, playerIn.posX, playerIn.posY + (double)(playerIn.height / 2.0F), playerIn.posZ); entityendereye.moveTowards(blockpos); worldIn.spawnEntityInWorld(entityendereye); worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_ENDEREYE_LAUNCH, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); worldIn.playEvent((EntityPlayer)null, 1003, new BlockPos(playerIn), 0); if (!playerIn.capabilities.isCreativeMode) { --itemStackIn.stackSize; } playerIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult(EnumActionResult.SUCCESS, itemStackIn); } } return new ActionResult(EnumActionResult.FAIL, itemStackIn); } }