net.minecraft.util.SoundCategory Java Examples

The following examples show how to use net.minecraft.util.SoundCategory. 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: ModuleShapeProjectile.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean run(@NotNull World world, ModuleInstanceShape instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	if (world.isRemote) return true;

	Vec3d origin = spell.getOriginWithFallback(world);
	if (origin == null) return false;

	double dist = spellRing.getAttributeValue(world, AttributeRegistry.RANGE, spell);
	double speed = spellRing.getAttributeValue(world, AttributeRegistry.SPEED, spell);

	if (!spellRing.taxCaster(world, spell, true)) return false;
	
	IShapeOverrides overrides = spellRing.getOverrideHandler().getConsumerInterface(IShapeOverrides.class);

	EntitySpellProjectile proj = new EntitySpellProjectile(world, spellRing, spell, (float) dist, (float) speed, (float) 0.1, !overrides.onRunProjectile(world, spell, spellRing));
	proj.setPosition(origin.x, origin.y, origin.z);
	proj.velocityChanged = true;

	boolean success = world.spawnEntity(proj);
	if (success)
		world.playSound(null, new BlockPos(origin), ModSounds.PROJECTILE_LAUNCH, SoundCategory.PLAYERS, 1f, (float) RandUtil.nextDouble(1, 1.5));
	return success;
}
 
Example #2
Source File: SteamBoiler.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void generateSteam() {
    if(currentTemperature >= 100) {
        if (getTimer() % getBoilingCycleLength() == 0) {
            int fillAmount = (int) (baseSteamOutput * (currentTemperature / (getMaxTemperate() * 1.0)));
            boolean hasDrainedWater = waterFluidTank.drain(1, true) != null;
            int filledSteam = 0;
            if (hasDrainedWater) {
                filledSteam = steamFluidTank.fill(ModHandler.getSteam(fillAmount), true);
            }
            if (this.hasNoWater && hasDrainedWater) {
                getWorld().setBlockToAir(getPos());
                getWorld().createExplosion(null,
                    getPos().getX() + 0.5, getPos().getY() + 0.5, getPos().getZ() + 0.5,
                    2.0f, true);
            } else this.hasNoWater = !hasDrainedWater;
            if (filledSteam == 0 && hasDrainedWater) {
                getWorld().playSound(null, getPos().getX() + 0.5, getPos().getY() + 0.5, getPos().getZ() + 0.5,
                    SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.0f);
                steamFluidTank.drain(4000, true);
            }
        }
    } else {
        this.hasNoWater = false;
    }
}
 
Example #3
Source File: RecipeLogicSteam.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void tryDoVenting() {
    BlockPos machinePos = metaTileEntity.getPos();
    EnumFacing ventingSide = getVentingSide();
    BlockPos ventingBlockPos = machinePos.offset(ventingSide);
    IBlockState blockOnPos = metaTileEntity.getWorld().getBlockState(ventingBlockPos);
    if (blockOnPos.getCollisionBoundingBox(metaTileEntity.getWorld(), ventingBlockPos) == Block.NULL_AABB) {
        metaTileEntity.getWorld()
            .getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(ventingBlockPos), EntitySelectors.CAN_AI_TARGET)
            .forEach(entity -> entity.attackEntityFrom(DamageSources.getHeatDamage(), 6.0f));
        WorldServer world = (WorldServer) metaTileEntity.getWorld();
        double posX = machinePos.getX() + 0.5 + ventingSide.getFrontOffsetX() * 0.6;
        double posY = machinePos.getY() + 0.5 + ventingSide.getFrontOffsetY() * 0.6;
        double posZ = machinePos.getZ() + 0.5 + ventingSide.getFrontOffsetZ() * 0.6;

        world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, posX, posY, posZ,
            7 + world.rand.nextInt(3),
            ventingSide.getFrontOffsetX() / 2.0,
            ventingSide.getFrontOffsetY() / 2.0,
            ventingSide.getFrontOffsetZ() / 2.0, 0.1);
        world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.0f);
        setNeedsVenting(false);
    } else if (!ventingStuck) {
        setVentingStuck(true);
    }
}
 
Example #4
Source File: ThrowableUranium238Handler.java    From Production-Line with MIT License 6 votes vote down vote up
@Override
public ActionResult<ItemStack> onRightClick(ItemStack itemStack, EntityPlayer entityPlayer, EnumHand hand) {
    ItemStack target = IC2Items.getItem("nuclear", "uranium_238");
    if (itemStack.isItemEqual(target)) {
        if (PLConfig.instance.throwableUran238) {
            if (!entityPlayer.capabilities.isCreativeMode) {
                --itemStack.stackSize;
            }

            entityPlayer.world.playSound(entityPlayer, entityPlayer.getPosition(),
                    SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS,
                    0.5F, 0.4F / (new Random().nextFloat() * 0.4F + 0.8F));
            if (!entityPlayer.world.isRemote) {
                entityPlayer.world.spawnEntity(new EntityThrownItem(entityPlayer.world, entityPlayer, itemStack));
            }
        }
        return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack);
    }
    return ActionResult.newResult(EnumActionResult.PASS, itemStack);
}
 
Example #5
Source File: ItemSlab.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
private boolean tryPlace(EntityPlayer player, ItemStack stack, World worldIn, BlockPos pos, int subtype)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() == this.singleSlab)
    {
        int subtype1 = singleSlabCS.getSubtype(iblockstate);

        if (subtype1 == subtype)
        {
            IBlockState stateDouble = this.makeState(subtype1);
            AxisAlignedBB axisalignedbb = stateDouble == null ? Block.NULL_AABB : stateDouble.getCollisionBoundingBox(worldIn, pos);

            if (stateDouble != null && axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) && worldIn.setBlockState(pos, stateDouble, 11))
            {
                SoundType soundtype = stateDouble.getBlock().getSoundType(stateDouble, worldIn, pos, player);
                worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
                stack.shrink(1);
            }

            return true;
        }
    }

    return false;
}
 
Example #6
Source File: TileEntityHandyChest.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void onLeftClickBlock(EntityPlayer player)
{
    if (this.getWorld().isRemote)
    {
        return;
    }

    Long last = this.clickTimes.get(player.getUniqueID());

    if (last != null && this.getWorld().getTotalWorldTime() - last < 5)
    {
        // Double left clicked fast enough (< 5 ticks) - do the selected item moving action
        this.performGuiAction(player, GUI_ACTION_MOVE_ITEMS, this.actionMode);
        this.getWorld().playSound(null, this.getPos(), SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 0.2f, 1.8f);
        this.clickTimes.remove(player.getUniqueID());
    }
    else
    {
        this.clickTimes.put(player.getUniqueID(), this.getWorld().getTotalWorldTime());
    }
}
 
Example #7
Source File: TileOxygenVent.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@Override
public void update() {

	if(canPerformFunction()) {

		if(hasEnoughEnergy(getPowerPerOperation())) {
			performFunction();
			if(!world.isRemote && isSealed) this.energy.extractEnergy(getPowerPerOperation(), false);
		}
		else
			notEnoughEnergyForFunction();
	}
	else
		radius = -1;
	if(!soundInit && world.isRemote) {
		LibVulpes.proxy.playSound(new RepeatingSound(AudioRegistry.airHissLoop, SoundCategory.BLOCKS, this));
	}
	soundInit = true;
}
 
Example #8
Source File: AutoFishModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void receivePacket(EventReceivePacket event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {

        if(event.getPacket() instanceof SPacketSoundEffect) {
            final SPacketSoundEffect packet = (SPacketSoundEffect) event.getPacket();
            if(packet.getCategory() == SoundCategory.NEUTRAL && packet.getSound() == SoundEvents.ENTITY_BOBBER_SPLASH) {
                final Minecraft mc = Minecraft.getMinecraft();

                if (mc.player.getHeldItemMainhand().getItem() instanceof ItemFishingRod) {
                    mc.player.connection.sendPacket(new CPacketPlayerTryUseItem(EnumHand.MAIN_HAND));
                    mc.player.swingArm(EnumHand.MAIN_HAND);
                    mc.player.connection.sendPacket(new CPacketPlayerTryUseItem(EnumHand.MAIN_HAND));
                    mc.player.swingArm(EnumHand.MAIN_HAND);
                }
            }
        }
    }
}
 
Example #9
Source File: ItemPebble.java    From ExNihiloAdscensio with MIT License 6 votes vote down vote up
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
    stack.stackSize--;
    
    world.playSound(player, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
    
    if (!world.isRemote)
    {
        ItemStack thrown = stack.copy();
        thrown.stackSize = 1;
        
        ProjectileStone projectile = new ProjectileStone(world, player);
        projectile.setStack(thrown);
        projectile.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 0.5F);
        world.spawnEntity(projectile);
    }
    
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
 
Example #10
Source File: ModuleEffectLight.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	BlockPos targetPos = spell.getTargetPos();
	EnumFacing facing = spell.getFaceHit();
	Entity caster = spell.getCaster(world);

	BlockPos finalPos = targetPos;
	if (facing != null && world.isAirBlock(targetPos.offset(facing))) finalPos = targetPos.offset(facing);
	if (!world.isAirBlock(finalPos)) return false;

	if (!spellRing.taxCaster(world, spell, true)) return false;

	if (targetPos == null) return true;

	BlockUtils.placeBlock(world, finalPos, ModBlocks.LIGHT.getDefaultState(), BlockUtils.makePlacer(world, finalPos, caster));
	TileLight te = BlockUtils.getTileEntity(world, finalPos, TileLight.class);
	if( te != null ) {
		// Should be always the case.
		te.setModule(instance);
	}

	world.playSound(null, targetPos, ModSounds.SPARKLE, SoundCategory.AMBIENT, 1f, 1f);

	return true;
}
 
Example #11
Source File: ModuleEffectGrace.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean runOnStart(@Nonnull World world, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	Entity entity = spell.getVictim(world);
	BlockPos pos = spell.getTargetPos();

	if (pos == null) return true;

	double time = spellRing.getAttributeValue(world, AttributeRegistry.DURATION, spell) * 10;

	if (!spellRing.taxCaster(world, spell, true)) return false;

	world.playSound(null, pos, ModSounds.GRACE, SoundCategory.NEUTRAL, RandUtil.nextFloat(0.6f, 1f), RandUtil.nextFloat(0.5f, 1f));
	if (entity instanceof EntityLivingBase) {
		((EntityLivingBase) entity).addPotionEffect(new PotionEffect(ModPotions.GRACE, (int) time, 0, true, false));
	}

	return true;
}
 
Example #12
Source File: GTTileCharcoalPit.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void updateProgress() {
	progress = progress + 1.0F;
	if (progress >= recipeOperation) {
		if (hasLogs()) {
			for (BlockPos logs : logPositions) {
				if (isLog(logs)) {
					world.setBlockState(logs, GTBlocks.brittleCharcoal.getDefaultState());
				}
			}
		}
		this.progress = 0;
		this.setActive(false);
		logPositions.clear();
		world.playSound((EntityPlayer) null, pos, SoundEvents.BLOCK_SAND_PLACE, SoundCategory.BLOCKS, 1.0F, 1.0F);
	}
}
 
Example #13
Source File: TileEntityBarrel.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
private boolean toggleCreativeMode(EntityPlayer player, boolean isStorageKey)
{
    if (isStorageKey || player.capabilities.isCreativeMode)
    {
        this.setCreative(! this.isCreative());
        this.markDirty();

        IBlockState state = this.getWorld().getBlockState(this.getPos());
        state = state.withProperty(BlockBarrel.CREATIVE, this.isCreative());
        this.getWorld().setBlockState(this.getPos(), state);

        if (isStorageKey)
        {
            this.getWorld().playSound(null, this.getPos(), SoundEvents.ENTITY_ITEMFRAME_REMOVE_ITEM, SoundCategory.BLOCKS, 0.7f, 1f);
        }

        return true;
    }

    return false;
}
 
Example #14
Source File: GTTileCharcoalPit.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public void randomTickDisplay(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
	if (this.isActive) {
		if (rand.nextInt(16) == 0) {
			worldIn.playSound((double) ((float) pos.getX() + 0.5F), (double) ((float) pos.getY()
					+ 0.5F), (double) ((float) pos.getZ()
							+ 0.5F), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.BLOCKS, 1.0F
									+ rand.nextFloat(), rand.nextFloat() * 0.7F + 0.3F, false);
		}
		for (int i = 0; i < 3; ++i) {
			double d0 = (double) pos.getX() + rand.nextDouble();
			double d1 = (double) pos.getY() + rand.nextDouble() * 0.5D + 0.5D;
			double d2 = (double) pos.getZ() + rand.nextDouble();
			worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0, d1, d2, 0.0D, 0.0D, 0.0D);
		}
	}
}
 
Example #15
Source File: ModuleEffectLowGravity.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #16
Source File: ModuleEffectBouncing.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean runOnStart(@Nonnull World world, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	Entity entity = spell.getVictim(world);

	BlockPos pos = spell.getTargetPos();
	if (pos == null) return true;

	double time = spellRing.getAttributeValue(world, AttributeRegistry.DURATION, spell) * 10;

	if (!spellRing.taxCaster(world, spell, true)) return false;

	if (entity instanceof EntityLivingBase) {
		BounceManager.INSTANCE.forEntity((EntityLivingBase) entity, (int) time);
	} else if (!BlockUtils.isAnyAir(world, pos)) {
		BounceManager.INSTANCE.forBlock(world, pos, (int) time);
		PacketHandler.NETWORK.sendToAll(new PacketAddBouncyBlock(world, pos, (int) time));
	}

	world.playSound(null, pos, ModSounds.SLIME_SQUISHING, SoundCategory.NEUTRAL, RandUtil.nextFloat(0.6f, 1f), RandUtil.nextFloat(0.5f, 1f));
	return true;
}
 
Example #17
Source File: TileEntityCrop.java    From AgriCraft with MIT License 6 votes vote down vote up
@Override
public boolean setCrossCrop(boolean status) {
    // If remote, change was failure.
    if (this.isRemote()) {
        return false;
    }

    // If we have a plant, change was a failure.
    if (this.hasSeed()) {
        return false;
    }

    // If the new state does not differ, change was a failure.
    if (this.crossCrop == status) {
        return false;
    }

    // Otherwise perform change.
    this.crossCrop = status;
    SoundType type = Blocks.PLANKS.getSoundType(null, null, null, null);
    this.getWorld().playSound(null, (double) ((float) xCoord() + 0.5F), (double) ((float) yCoord() + 0.5F), (double) ((float) zCoord() + 0.5F), type.getPlaceSound(), SoundCategory.BLOCKS, (type.getVolume() + 1.0F) / 2.0F, type.getPitch() * 0.8F);
    this.markForUpdate();

    // Operation was a success!
    return true;
}
 
Example #18
Source File: BlockElectricMushroom.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World world,
		BlockPos pos, Random rand) {
	
	super.randomDisplayTick(stateIn, world, pos, rand);
	if(world.getTotalWorldTime() % 100 == 0 && world.getBiome(pos) == AdvancedRocketryBiomes.stormLandsBiome) {
		FxSystemElectricArc.spawnArc(world, pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f, .3, 7);
		world.playSound(Minecraft.getMinecraft().player, pos, AudioRegistry.electricShockSmall, SoundCategory.BLOCKS, .7f,  0.975f + world.rand.nextFloat()*0.05f);
	}
}
 
Example #19
Source File: CraftWorld.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
    if (loc == null || sound == null || category == null) {
        return;
    }

    double x = loc.getX();
    double y = loc.getY();
    double z = loc.getZ();

    getHandle().playSound(null, x, y, z, CraftSound.getSoundEffect(CraftSound.getSound(sound)), SoundCategory.valueOf(category.name()), volume, pitch); // PAIL: rename
}
 
Example #20
Source File: ModuleEffectSonic.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	Entity targetEntity = spell.getVictim(world);
	Entity caster = spell.getCaster(world);
	BlockPos pos = spell.getTargetPos();

	if (pos == null) return false;

	double potency = spellRing.getAttributeValue(world, AttributeRegistry.POTENCY, spell) / 2;
	double area = spellRing.getAttributeValue(world, AttributeRegistry.AREA, spell) / 2;

	if (!spellRing.taxCaster(world, spell, true)) return false;

	if (targetEntity instanceof EntityLivingBase) {
		world.playSound(null, pos, ModSounds.SOUND_BOMB, SoundCategory.NEUTRAL, 1, RandUtil.nextFloat(0.8f, 1.2f));
		damageEntity((EntityLivingBase) targetEntity, caster, (float) potency);

		if (((EntityLivingBase) targetEntity).getHealth() <= 0) {
			Vec3d targetPos = targetEntity.getPositionVector();
			double sqArea = area * area;
			AxisAlignedBB aabb = new AxisAlignedBB(targetEntity.getPosition()).grow(area);
			world.getEntitiesWithinAABB(EntityLivingBase.class, aabb).stream()
					.filter(entity -> entity.getPositionVector().squareDistanceTo(targetPos) < sqArea)
					.forEach(entity -> damageEntity(entity, caster, (float) potency));
		}
	}
	return true;
}
 
Example #21
Source File: ItemOwlEgg.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
  ItemStack itemStackIn = playerIn.getHeldItem(hand);
  if (!playerIn.capabilities.isCreativeMode) {
    itemStackIn.shrink(1);
  }
  worldIn.playSound(playerIn, playerIn.getPosition(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.BLOCKS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
  if (!worldIn.isRemote) {    
    EntityOwlEgg entityEgg = new EntityOwlEgg(worldIn, playerIn);
    //without setHeading the egg just falls to the players feet
    entityEgg.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, PITCHOFFSET, VELOCITY_DEFAULT, INACCURACY_DEFAULT);
    worldIn.spawnEntity(entityEgg);
  }
  return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
}
 
Example #22
Source File: ItemEnderPearlReusable.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
    ItemStack stack = player.getHeldItem(hand);

    if (world.isRemote)
    {
        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
    }

    // Damage 1: "Elite version" of the pearl, makes the thrower fly with it. Idea by xisumavoid in episode Hermitcraft III 303 :)

    EntityEnderPearlReusable pearl = new EntityEnderPearlReusable(world, player, stack.getMetadata() == 1);
    float velocity = stack.getMetadata() == 1 ? 2.5f : 1.9f;
    pearl.shoot(player, player.rotationPitch, player.rotationYaw, 0.0f, velocity, 0.8f);
    world.spawnEntity(pearl);

    if (stack.getMetadata() == 1)
    {
        Entity bottomEntity = player.getLowestRidingEntity();

        // Dismount the previous pearl if we are already riding one
        // (by selecting the entity riding that pearl to be the one mounted to the new pearl)
        if (bottomEntity instanceof EntityEnderPearlReusable)
        {
            bottomEntity = bottomEntity.getPassengers().get(0);
        }

        bottomEntity.startRiding(pearl);
    }

    stack.shrink(1);

    world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERPEARL_THROW,
            SoundCategory.MASTER, 0.5f, 0.4f / (itemRand.nextFloat() * 0.4f + 0.8f));

    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
 
Example #23
Source File: PotionTimeSlow.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void removeAttributesModifiersFromEntity(EntityLivingBase entityLivingBaseIn, @Nonnull AbstractAttributeMap attributeMapIn, int amplifier) {
	super.removeAttributesModifiersFromEntity(entityLivingBaseIn, attributeMapIn, amplifier);
	if (timeScale(entityLivingBaseIn) == 0 && entityLivingBaseIn instanceof EntityCreature) {
		((EntityLiving) entityLivingBaseIn).setNoAI(false);
	}

	entityLivingBaseIn.world.playSound(null, entityLivingBaseIn.getPosition(), ModSounds.SLOW_MOTION_OUT, SoundCategory.NEUTRAL, 1f, 1);
}
 
Example #24
Source File: ModuleEffectLeap.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	Vec3d lookVec = spell.getData(LOOK);
	Entity target = spell.getVictim(world);

	if (!(target instanceof EntityLivingBase)) return true;

	ItemStack stack = ((EntityLivingBase) target).getHeldItemMainhand();
	if (stack.isEmpty()) return true;
	if (lookVec == null) return true;

	if (!target.hasNoGravity()) {
		double potency = spellRing.getAttributeValue(world, AttributeRegistry.POTENCY, spell);
		if (!spellRing.taxCaster(world, spell, true)) return false;

		if (!NBTHelper.hasNBTEntry(stack, "jump_count")
				|| !NBTHelper.hasNBTEntry(stack, "max_jumps")
				|| !NBTHelper.hasNBTEntry(stack, "jump_timer")) {
			NBTHelper.setInt(stack, "jump_count", (int) potency);
			NBTHelper.setInt(stack, "max_jumps", (int) potency);
			NBTHelper.setInt(stack, "jump_timer", 200);
		}

		target.motionX += lookVec.x;
		target.motionY += 0.65;
		target.motionZ += lookVec.z;

		target.velocityChanged = true;
		target.fallDistance /= (1 + MathHelper.ceil(spellRing.getAttributeValue(world, AttributeRegistry.POTENCY, spell) / 8));

		if (target instanceof EntityPlayerMP)
			((EntityPlayerMP) target).connection.sendPacket(new SPacketEntityVelocity(target));
		world.playSound(null, target.getPosition(), ModSounds.FLY, SoundCategory.NEUTRAL, 1, 1);
	}
	return true;
}
 
Example #25
Source File: TilePuzzle.java    From YouTubeModdingTutorial with MIT License 5 votes vote down vote up
public void activate(IBlockState state) {
    Boolean open = state.getValue(BlockPuzzle.OPEN);
    if (open) {
        // Already open, do nothing
        return;
    }
    if (item.isEmpty()) {
        // No game, do nothing
        return;
    }

    Set<BlockPos> blocks = findParticipatingBlocks();
    if (isDisplayingBadSolution(blocks)) {
        // We are temporarily displaying a bad solution. Do nothing
        return;
    }

    int cnt = countOpenUnsolvedBlocks(blocks);
    if (cnt == 0) {
        // We can open
        openMe();
    } else if (cnt == 1) {
        // We can also open. Check status
        openMe();
        boolean goodsolution = checkSolution(blocks);
        if (goodsolution) {
            markSolved(blocks);
            world.playSound(null, pos, SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.BLOCKS, 1.0f, 1.0f);
        } else {
            setBadTimer(blocks);
            world.playSound(null, pos, SoundEvents.ENTITY_VILLAGER_NO, SoundCategory.BLOCKS, 1.0f, 1.0f);
        }
    }

}
 
Example #26
Source File: PotionTimeSlow.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void applyAttributesModifiersToEntity(EntityLivingBase entityLivingBaseIn, @Nonnull AbstractAttributeMap attributeMapIn, int amplifier) {
	super.applyAttributesModifiersToEntity(entityLivingBaseIn, attributeMapIn, amplifier);

	if (timeScale(entityLivingBaseIn) == 0 && entityLivingBaseIn instanceof EntityCreature) {
		((EntityLiving) entityLivingBaseIn).setNoAI(true);

		if(entityLivingBaseIn instanceof EntityCreeper) {
			((EntityCreeper)entityLivingBaseIn).setCreeperState(-1);
		}
	}

	entityLivingBaseIn.world.playSound(null, entityLivingBaseIn.getPosition(), ModSounds.SLOW_MOTION_IN, SoundCategory.NEUTRAL, 1f, 1);
}
 
Example #27
Source File: TaskPositionDebug.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean execute()
{
    World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(this.dimension);
    if (world == null)
    {
        return true;
    }

    for (int i = 0; i < this.blocksPerTick; i++)
    {
        if (this.listIndex >= this.positions.size())
        {
            return true;
        }

        int meta = this.listIndex & 0xF;
        BlockPos pos = this.positions.get(this.listIndex++);

        if (this.placeBlocks)
        {
            IBlockState state = this.blockState != null ? this.blockState : Blocks.STAINED_GLASS.getStateFromMeta(meta);

            world.setBlockState(pos, state, 3);
            world.playSound(null, pos, state.getBlock().getSoundType(state, world, pos, null).getPlaceSound(), SoundCategory.BLOCKS, 1.0f, 1.0f);
        }

        if (this.useParticles)
        {
            Effects.spawnParticlesFromServer(this.dimension, pos, this.particle, 1);
        }

        this.count++;
    }

    return false;
}
 
Example #28
Source File: SpellRing.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public boolean taxCaster(@Nonnull World world, SpellData data, double multiplier, boolean failSound) {
	if(data.getData(SpellData.DefaultKeys.CASTER) == null) return true;

	Entity caster = world.getEntityByID(data.getData(SpellData.DefaultKeys.CASTER));

	if(caster == null) {
		Wizardry.LOGGER.warn("Caster was null!");
		return true;
	}

	IManaCapability cap = ManaCapabilityProvider.getCap(caster);
	if (cap == null) return false;

	double manaDrain = getManaDrain(data) * multiplier;
	double burnoutFill = getBurnoutFill(data) * multiplier;

	boolean fail = false;

	try (ManaManager.CapManagerBuilder mgr = ManaManager.forObject(cap)) {
		if (mgr.getMana() < manaDrain) fail = true;

		mgr.removeMana(manaDrain);
		mgr.addBurnout(burnoutFill);
	}

	if (fail && failSound) {

		Vec3d origin = data.getOriginWithFallback(world);
		if (origin != null)
			world.playSound(null, new BlockPos(origin), ModSounds.SPELL_FAIL, SoundCategory.NEUTRAL, 1f, 1f);
	}

	return !fail;
}
 
Example #29
Source File: BlockElevator.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player,
        EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
    ItemStack stack = EntityUtils.getHeldItemOfType(player, ItemDye.class);

    if (stack.isEmpty() == false)
    {
        EnumDyeColor stackColor = EnumDyeColor.byDyeDamage(stack.getMetadata());

        if (state.getValue(COLOR) != stackColor)
        {
            if (world.isRemote == false)
            {
                world.setBlockState(pos, state.withProperty(COLOR, stackColor), 3);
                world.playSound(null, pos, SoundEvents.ENTITY_ITEMFRAME_ADD_ITEM, SoundCategory.BLOCKS, 1f, 1f);

                if (player.capabilities.isCreativeMode == false)
                {
                    stack.shrink(1);
                }
            }

            return true;
        }

        return false;
    }
    else
    {
        return super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ);
    }
}
 
Example #30
Source File: BlockConfusingCharge.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@Override
public void explode(EntityPrimedCharge entity) {
  World world = entity.getEntityWorld();

  world.playSound((EntityPlayer)null, entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 3F, 1.4f + ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F));

  PacketHandler.sendToAllAround(new PacketExplodeEffect(entity, this), entity);
}