Java Code Examples for net.minecraft.world.World.spawnEntityInWorld()

The following are Jave code examples for showing how to use spawnEntityInWorld() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: CustomWorldGen   File: ItemSnowball.java   Source Code and License Vote up 6 votes
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        EntitySnowball entitysnowball = new EntitySnowball(worldIn, playerIn);
        entitysnowball.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        worldIn.spawnEntityInWorld(entitysnowball);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
 
Example 2
Project: minecraft-quiverbow   File: OWR.java   Source Code and License Vote up 6 votes
private void dropMagazine(World world, ItemStack stack, Entity entity)
{
	if (!(entity instanceof EntityPlayer)) // For QuiverMobs/Arms Assistants
	{
		this.setCooldown(stack, 60);
		return;
	}

	ItemStack clipStack = Helper.getAmmoStack(ObsidianMagazine.class, stack.getItemDamage());	// Unloading all ammo into that clip

	stack.setItemDamage(this.getMaxDamage());	// Emptying out

	// Creating the clip
	EntityItem entityitem = new EntityItem(world, entity.posX, entity.posY + 1.0d, entity.posZ, clipStack);
	entityitem.delayBeforeCanPickup = 10;

	// And dropping it
	if (entity.captureDrops) { entity.capturedDrops.add(entityitem); }
	else { world.spawnEntityInWorld(entityitem); }

	// SFX
	world.playSoundAtEntity(entity, "random.click", 1.7F, 0.3F);
}
 
Example 3
Project: minecraft-quiverbow   File: DragonBox.java   Source Code and License Vote up 6 votes
@Override
public void doSingleFire(ItemStack stack, World world, Entity entity)		// Server side
{
	if (this.getCooldown(stack) != 0) { return; }	// Hasn't cooled down yet

	// Random Damage
	int dmg_range = this.DmgMax - this.DmgMin; 		// If max dmg is 20 and min is 10, then the range will be 10
	int dmg = world.rand.nextInt(dmg_range + 1);	// Range will be between 0 and 10
	dmg += this.DmgMin;								// Adding the min dmg of 10 back on top, giving us the proper damage range (10-20)

	// SFX
	world.playSoundAtEntity(entity, "fireworks.launch", 1.0F, 1.0F);

	// Firing
	SmallRocket shot = new SmallRocket(world, entity, (float) this.Speed, 0, 0);

	shot.damage = dmg;
	shot.fireDuration = this.FireDur;
	shot.explosionSize = this.ExplosionSize;
	shot.dmgTerrain = this.dmgTerrain;

	world.spawnEntityInWorld(shot);

	this.consumeAmmo(stack, entity, 1);
	this.setCooldown(stack, this.Cooldown);
}
 
Example 4
Project: minecraft-quiverbow   File: SugarEngine.java   Source Code and License Vote up 6 votes
private void dropMagazine(World world, ItemStack stack, Entity entity)
{
	if (!(entity instanceof EntityPlayer)) // For QuiverMobs/Arms Assistants
	{
		this.setCooldown(stack, 80);
		return;
	}

	ItemStack clipStack = Helper.getAmmoStack(GatlingAmmo.class, stack.getItemDamage());	// Unloading all ammo into that clip

	stack.setItemDamage(this.getMaxDamage());	// Emptying out

	// Creating the clip
	EntityItem entityitem = new EntityItem(world, entity.posX, entity.posY + 1.0d, entity.posZ, clipStack);
	entityitem.delayBeforeCanPickup = 10;

	// And dropping it
	if (entity.captureDrops) { entity.capturedDrops.add(entityitem); }
	else { world.spawnEntityInWorld(entityitem); }

	// SFX
	world.playSoundAtEntity(entity, "random.break", 1.0F, 0.5F);
}
 
Example 5
Project: CustomWorldGen   File: StructureMineshaftPieces.java   Source Code and License Vote up 6 votes
/**
 * Adds chest to the structure and sets its contents
 */
protected boolean generateChest(World worldIn, StructureBoundingBox structurebb, Random randomIn, int x, int y, int z, ResourceLocation loot)
{
    BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));

    if (structurebb.isVecInside(blockpos) && worldIn.getBlockState(blockpos).getMaterial() == Material.AIR && worldIn.getBlockState(blockpos.down()).getMaterial() != Material.AIR)
    {
        IBlockState iblockstate = Blocks.RAIL.getDefaultState().withProperty(BlockRail.SHAPE, randomIn.nextBoolean() ? BlockRailBase.EnumRailDirection.NORTH_SOUTH : BlockRailBase.EnumRailDirection.EAST_WEST);
        this.setBlockState(worldIn, iblockstate, x, y, z, structurebb);
        EntityMinecartChest entityminecartchest = new EntityMinecartChest(worldIn, (double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.5F), (double)((float)blockpos.getZ() + 0.5F));
        entityminecartchest.setLootTable(loot, randomIn.nextLong());
        worldIn.spawnEntityInWorld(entityminecartchest);
        return true;
    }
    else
    {
        return false;
    }
}
 
Example 6
Project: minecraft-quiverbow   File: Endernymous.java   Source Code and License Vote up 6 votes
private void dropMagazine(World world, ItemStack stack, Entity entity)
{
	if (!(entity instanceof EntityPlayer)) // For QuiverMobs/Arms Assistants
	{
		this.setCooldown(stack, 60);
		return;
	}

	ItemStack clipStack = Helper.getAmmoStack(EnderQuartzClip.class, stack.getItemDamage());	// Unloading all ammo into that clip

	stack.setItemDamage(this.getMaxDamage());	// Emptying out

	// Creating the clip
	EntityItem entityitem = new EntityItem(world, entity.posX, entity.posY + 1.0d, entity.posZ, clipStack);
	entityitem.delayBeforeCanPickup = 10;

	// And dropping it
	if (entity.captureDrops) { entity.capturedDrops.add(entityitem); }
	else { world.spawnEntityInWorld(entityitem); }

	// SFX
	world.playSoundAtEntity(entity, "random.break", 1.0F, 0.3F);
}
 
Example 7
Project: DecompiledMinecraft   File: ItemEnderPearl.java   Source Code and License Vote up 6 votes
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (playerIn.capabilities.isCreativeMode)
    {
        return itemStackIn;
    }
    else
    {
        --itemStackIn.stackSize;
        worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!worldIn.isRemote)
        {
            worldIn.spawnEntityInWorld(new EntityEnderPearl(worldIn, playerIn));
        }

        playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
        return itemStackIn;
    }
}
 
Example 8
Project: DecompiledMinecraft   File: ItemExpBottle.java   Source Code and License Vote up 6 votes
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        worldIn.spawnEntityInWorld(new EntityExpBottle(worldIn, playerIn));
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
 
Example 9
Project: BaseClient   File: ItemFirework.java   Source Code and License Vote up 6 votes
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (!worldIn.isRemote)
    {
        EntityFireworkRocket entityfireworkrocket = new EntityFireworkRocket(worldIn, (double)((float)pos.getX() + hitX), (double)((float)pos.getY() + hitY), (double)((float)pos.getZ() + hitZ), stack);
        worldIn.spawnEntityInWorld(entityfireworkrocket);

        if (!playerIn.capabilities.isCreativeMode)
        {
            --stack.stackSize;
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 10
Project: DecompiledMinecraft   File: StructureOceanMonumentPieces.java   Source Code and License Vote up 6 votes
protected boolean func_175817_a(World worldIn, StructureBoundingBox p_175817_2_, int p_175817_3_, int p_175817_4_, int p_175817_5_)
{
    int i = this.getXWithOffset(p_175817_3_, p_175817_5_);
    int j = this.getYWithOffset(p_175817_4_);
    int k = this.getZWithOffset(p_175817_3_, p_175817_5_);

    if (p_175817_2_.isVecInside(new BlockPos(i, j, k)))
    {
        EntityGuardian entityguardian = new EntityGuardian(worldIn);
        entityguardian.setElder(true);
        entityguardian.heal(entityguardian.getMaxHealth());
        entityguardian.setLocationAndAngles((double)i + 0.5D, (double)j, (double)k + 0.5D, 0.0F, 0.0F);
        entityguardian.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(entityguardian)), (IEntityLivingData)null);
        worldIn.spawnEntityInWorld(entityguardian);
        return true;
    }
    else
    {
        return false;
    }
}
 
Example 11
Project: CustomWorldGen   File: BlockDragonEgg.java   Source Code and License Vote up 5 votes
private void checkFall(World worldIn, BlockPos pos)
{
    if (worldIn.isAirBlock(pos.down()) && BlockFalling.canFallThrough(worldIn.getBlockState(pos.down())) && pos.getY() >= 0)
    {
        int i = 32;

        if (!BlockFalling.fallInstantly && worldIn.isAreaLoaded(pos.add(-32, -32, -32), pos.add(32, 32, 32)))
        {
            worldIn.spawnEntityInWorld(new EntityFallingBlock(worldIn, (double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F), this.getDefaultState()));
        }
        else
        {
            worldIn.setBlockToAir(pos);
            BlockPos blockpos;

            for (blockpos = pos; worldIn.isAirBlock(blockpos) && BlockFalling.canFallThrough(worldIn.getBlockState(blockpos)) && blockpos.getY() > 0; blockpos = blockpos.down())
            {
                ;
            }

            if (blockpos.getY() > 0)
            {
                worldIn.setBlockState(blockpos, this.getDefaultState(), 2);
            }
        }
    }
}
 
Example 12
Project: DecompiledMinecraft   File: ItemMinecart.java   Source Code and License Vote up 5 votes
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (BlockRailBase.isRailBlock(iblockstate))
    {
        if (!worldIn.isRemote)
        {
            BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
            double d0 = 0.0D;

            if (blockrailbase$enumraildirection.isAscending())
            {
                d0 = 0.5D;
            }

            EntityMinecart entityminecart = EntityMinecart.func_180458_a(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.0625D + d0, (double)pos.getZ() + 0.5D, this.minecartType);

            if (stack.hasDisplayName())
            {
                entityminecart.setCustomNameTag(stack.getDisplayName());
            }

            worldIn.spawnEntityInWorld(entityminecart);
        }

        --stack.stackSize;
        return true;
    }
    else
    {
        return false;
    }
}
 
Example 13
Project: Backmemed   File: BlockJukebox.java   Source Code and License Vote up 5 votes
private void dropRecord(World worldIn, BlockPos pos, IBlockState state)
{
    if (!worldIn.isRemote)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof BlockJukebox.TileEntityJukebox)
        {
            BlockJukebox.TileEntityJukebox blockjukebox$tileentityjukebox = (BlockJukebox.TileEntityJukebox)tileentity;
            ItemStack itemstack = blockjukebox$tileentityjukebox.getRecord();

            if (!itemstack.func_190926_b())
            {
                worldIn.playEvent(1010, pos, 0);
                worldIn.playRecord(pos, (SoundEvent)null);
                blockjukebox$tileentityjukebox.setRecord(ItemStack.field_190927_a);
                float f = 0.7F;
                double d0 = (double)(worldIn.rand.nextFloat() * 0.7F) + 0.15000000596046448D;
                double d1 = (double)(worldIn.rand.nextFloat() * 0.7F) + 0.06000000238418579D + 0.6D;
                double d2 = (double)(worldIn.rand.nextFloat() * 0.7F) + 0.15000000596046448D;
                ItemStack itemstack1 = itemstack.copy();
                EntityItem entityitem = new EntityItem(worldIn, (double)pos.getX() + d0, (double)pos.getY() + d1, (double)pos.getZ() + d2, itemstack1);
                entityitem.setDefaultPickupDelay();
                worldIn.spawnEntityInWorld(entityitem);
            }
        }
    }
}
 
Example 14
Project: minecraft-quiverbow   File: SeedSweeper.java   Source Code and License Vote up 5 votes
private void fireShot(World world, Entity entity)
{
	float spreadHor = world.rand.nextFloat() * this.Spread - (this.Spread / 2);
	float spreadVert = world.rand.nextFloat() * this.Spread - (this.Spread / 2);

	Seed shot = new Seed(world, entity, (float) this.Speed, spreadHor, spreadVert);
	shot.damage = this.Dmg;

	world.spawnEntityInWorld(shot); 											// Firing
}
 
Example 15
Project: BaseClient   File: ItemMinecart.java   Source Code and License Vote up 5 votes
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (BlockRailBase.isRailBlock(iblockstate))
    {
        if (!worldIn.isRemote)
        {
            BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
            double d0 = 0.0D;

            if (blockrailbase$enumraildirection.isAscending())
            {
                d0 = 0.5D;
            }

            EntityMinecart entityminecart = EntityMinecart.func_180458_a(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.0625D + d0, (double)pos.getZ() + 0.5D, this.minecartType);

            if (stack.hasDisplayName())
            {
                entityminecart.setCustomNameTag(stack.getDisplayName());
            }

            worldIn.spawnEntityInWorld(entityminecart);
        }

        --stack.stackSize;
        return true;
    }
    else
    {
        return false;
    }
}
 
Example 16
Project: minecraft-quiverbow   File: OSR.java   Source Code and License Vote up 5 votes
@Override
public void doSingleFire(ItemStack stack, World world, Entity entity)		// Server side
{
	if (this.getCooldown(stack) > 0) { return; }	// Hasn't cooled down yet

	// Good to go (already verified)
	Helper.knockUserBack(entity, this.Kickback);			// Kickback

	// Firing
	OSR_Shot projectile = new OSR_Shot(world, entity, (float) this.Speed);

	// Random Damage
	int dmg_range = this.DmgMax - this.DmgMin; 				// If max dmg is 20 and min is 10, then the range will be 10
	int dmg = world.rand.nextInt(dmg_range + 1);	// Range will be between 0 and 10
	dmg += this.DmgMin;									// Adding the min dmg of 10 back on top, giving us the proper damage range (10-20)

	projectile.damage = dmg;

	ShotPotion effect1 = new ShotPotion();

	effect1.potion = Potion.wither;
	effect1.Strength = this.Wither_Strength;
	effect1.Duration = this.Wither_Duration;

	projectile.pot1 = effect1;

	world.spawnEntityInWorld(projectile); 			// Firing!

	// SFX
	world.playSoundAtEntity(entity, "random.explode", 0.5F, 1.5F);
	NetHelper.sendParticleMessageToAllPlayers(world, entity.getEntityId(), (byte) 3, (byte) 4);	// smoke

	this.setCooldown(stack, this.Cooldown);
	if (this.consumeAmmo(stack, entity, 1)) { this.dropMagazine(world, stack, entity); }
}
 
Example 17
Project: BaseClient   File: BlockJukebox.java   Source Code and License Vote up 5 votes
private void dropRecord(World worldIn, BlockPos pos, IBlockState state)
{
    if (!worldIn.isRemote)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof BlockJukebox.TileEntityJukebox)
        {
            BlockJukebox.TileEntityJukebox blockjukebox$tileentityjukebox = (BlockJukebox.TileEntityJukebox)tileentity;
            ItemStack itemstack = blockjukebox$tileentityjukebox.getRecord();

            if (itemstack != null)
            {
                worldIn.playAuxSFX(1005, pos, 0);
                worldIn.playRecord(pos, (String)null);
                blockjukebox$tileentityjukebox.setRecord((ItemStack)null);
                float f = 0.7F;
                double d0 = (double)(worldIn.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
                double d1 = (double)(worldIn.rand.nextFloat() * f) + (double)(1.0F - f) * 0.2D + 0.6D;
                double d2 = (double)(worldIn.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
                ItemStack itemstack1 = itemstack.copy();
                EntityItem entityitem = new EntityItem(worldIn, (double)pos.getX() + d0, (double)pos.getY() + d1, (double)pos.getZ() + d2, itemstack1);
                entityitem.setDefaultPickupDelay();
                worldIn.spawnEntityInWorld(entityitem);
            }
        }
    }
}
 
Example 18
Project: BaseClient   File: BehaviorProjectileDispense.java   Source Code and License Vote up 5 votes
/**
 * Dispense the specified stack, play the dispense sound and spawn particles.
 */
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
    World world = source.getWorld();
    IPosition iposition = BlockDispenser.getDispensePosition(source);
    EnumFacing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
    IProjectile iprojectile = this.getProjectileEntity(world, iposition);
    iprojectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + 0.1F), (double)enumfacing.getFrontOffsetZ(), this.func_82500_b(), this.func_82498_a());
    world.spawnEntityInWorld((Entity)iprojectile);
    stack.splitStack(1);
    return stack;
}
 
Example 19
Project: DecompiledMinecraft   File: ComponentScatteredFeaturePieces.java   Source Code and License Vote up 4 votes
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
{
    if (!this.func_74935_a(worldIn, structureBoundingBoxIn, 0))
    {
        return false;
    }
    else
    {
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 1, 5, 1, 7, Blocks.planks.getStateFromMeta(BlockPlanks.EnumType.SPRUCE.getMetadata()), Blocks.planks.getStateFromMeta(BlockPlanks.EnumType.SPRUCE.getMetadata()), false);
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 4, 2, 5, 4, 7, Blocks.planks.getStateFromMeta(BlockPlanks.EnumType.SPRUCE.getMetadata()), Blocks.planks.getStateFromMeta(BlockPlanks.EnumType.SPRUCE.getMetadata()), false);
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 2, 1, 0, 4, 1, 0, Blocks.planks.getStateFromMeta(BlockPlanks.EnumType.SPRUCE.getMetadata()), Blocks.planks.getStateFromMeta(BlockPlanks.EnumType.SPRUCE.getMetadata()), false);
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 2, 2, 2, 3, 3, 2, Blocks.planks.getStateFromMeta(BlockPlanks.EnumType.SPRUCE.getMetadata()), Blocks.planks.getStateFromMeta(BlockPlanks.EnumType.SPRUCE.getMetadata()), false);
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 2, 3, 1, 3, 6, Blocks.planks.getStateFromMeta(BlockPlanks.EnumType.SPRUCE.getMetadata()), Blocks.planks.getStateFromMeta(BlockPlanks.EnumType.SPRUCE.getMetadata()), false);
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 5, 2, 3, 5, 3, 6, Blocks.planks.getStateFromMeta(BlockPlanks.EnumType.SPRUCE.getMetadata()), Blocks.planks.getStateFromMeta(BlockPlanks.EnumType.SPRUCE.getMetadata()), false);
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 2, 2, 7, 4, 3, 7, Blocks.planks.getStateFromMeta(BlockPlanks.EnumType.SPRUCE.getMetadata()), Blocks.planks.getStateFromMeta(BlockPlanks.EnumType.SPRUCE.getMetadata()), false);
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 0, 2, 1, 3, 2, Blocks.log.getDefaultState(), Blocks.log.getDefaultState(), false);
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 5, 0, 2, 5, 3, 2, Blocks.log.getDefaultState(), Blocks.log.getDefaultState(), false);
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 0, 7, 1, 3, 7, Blocks.log.getDefaultState(), Blocks.log.getDefaultState(), false);
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 5, 0, 7, 5, 3, 7, Blocks.log.getDefaultState(), Blocks.log.getDefaultState(), false);
        this.setBlockState(worldIn, Blocks.oak_fence.getDefaultState(), 2, 3, 2, structureBoundingBoxIn);
        this.setBlockState(worldIn, Blocks.oak_fence.getDefaultState(), 3, 3, 7, structureBoundingBoxIn);
        this.setBlockState(worldIn, Blocks.air.getDefaultState(), 1, 3, 4, structureBoundingBoxIn);
        this.setBlockState(worldIn, Blocks.air.getDefaultState(), 5, 3, 4, structureBoundingBoxIn);
        this.setBlockState(worldIn, Blocks.air.getDefaultState(), 5, 3, 5, structureBoundingBoxIn);
        this.setBlockState(worldIn, Blocks.flower_pot.getDefaultState().withProperty(BlockFlowerPot.CONTENTS, BlockFlowerPot.EnumFlowerType.MUSHROOM_RED), 1, 3, 5, structureBoundingBoxIn);
        this.setBlockState(worldIn, Blocks.crafting_table.getDefaultState(), 3, 2, 6, structureBoundingBoxIn);
        this.setBlockState(worldIn, Blocks.cauldron.getDefaultState(), 4, 2, 6, structureBoundingBoxIn);
        this.setBlockState(worldIn, Blocks.oak_fence.getDefaultState(), 1, 2, 1, structureBoundingBoxIn);
        this.setBlockState(worldIn, Blocks.oak_fence.getDefaultState(), 5, 2, 1, structureBoundingBoxIn);
        int i = this.getMetadataWithOffset(Blocks.oak_stairs, 3);
        int j = this.getMetadataWithOffset(Blocks.oak_stairs, 1);
        int k = this.getMetadataWithOffset(Blocks.oak_stairs, 0);
        int l = this.getMetadataWithOffset(Blocks.oak_stairs, 2);
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 4, 1, 6, 4, 1, Blocks.spruce_stairs.getStateFromMeta(i), Blocks.spruce_stairs.getStateFromMeta(i), false);
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 4, 2, 0, 4, 7, Blocks.spruce_stairs.getStateFromMeta(k), Blocks.spruce_stairs.getStateFromMeta(k), false);
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 6, 4, 2, 6, 4, 7, Blocks.spruce_stairs.getStateFromMeta(j), Blocks.spruce_stairs.getStateFromMeta(j), false);
        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 4, 8, 6, 4, 8, Blocks.spruce_stairs.getStateFromMeta(l), Blocks.spruce_stairs.getStateFromMeta(l), false);

        for (int i1 = 2; i1 <= 7; i1 += 5)
        {
            for (int j1 = 1; j1 <= 5; j1 += 4)
            {
                this.replaceAirAndLiquidDownwards(worldIn, Blocks.log.getDefaultState(), j1, -1, i1, structureBoundingBoxIn);
            }
        }

        if (!this.hasWitch)
        {
            int l1 = this.getXWithOffset(2, 5);
            int i2 = this.getYWithOffset(2);
            int k1 = this.getZWithOffset(2, 5);

            if (structureBoundingBoxIn.isVecInside(new BlockPos(l1, i2, k1)))
            {
                this.hasWitch = true;
                EntityWitch entitywitch = new EntityWitch(worldIn);
                entitywitch.setLocationAndAngles((double)l1 + 0.5D, (double)i2, (double)k1 + 0.5D, 0.0F, 0.0F);
                entitywitch.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(l1, i2, k1)), (IEntityLivingData)null);
                worldIn.spawnEntityInWorld(entitywitch);
            }
        }

        return true;
    }
}
 
Example 20
Project: DecompiledMinecraft   File: BlockPumpkin.java   Source Code and License Vote up 4 votes
private void trySpawnGolem(World worldIn, BlockPos pos)
{
    BlockPattern.PatternHelper blockpattern$patternhelper;

    if ((blockpattern$patternhelper = this.getSnowmanPattern().match(worldIn, pos)) != null)
    {
        for (int i = 0; i < this.getSnowmanPattern().getThumbLength(); ++i)
        {
            BlockWorldState blockworldstate = blockpattern$patternhelper.translateOffset(0, i, 0);
            worldIn.setBlockState(blockworldstate.getPos(), Blocks.air.getDefaultState(), 2);
        }

        EntitySnowman entitysnowman = new EntitySnowman(worldIn);
        BlockPos blockpos1 = blockpattern$patternhelper.translateOffset(0, 2, 0).getPos();
        entitysnowman.setLocationAndAngles((double)blockpos1.getX() + 0.5D, (double)blockpos1.getY() + 0.05D, (double)blockpos1.getZ() + 0.5D, 0.0F, 0.0F);
        worldIn.spawnEntityInWorld(entitysnowman);

        for (int j = 0; j < 120; ++j)
        {
            worldIn.spawnParticle(EnumParticleTypes.SNOW_SHOVEL, (double)blockpos1.getX() + worldIn.rand.nextDouble(), (double)blockpos1.getY() + worldIn.rand.nextDouble() * 2.5D, (double)blockpos1.getZ() + worldIn.rand.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]);
        }

        for (int i1 = 0; i1 < this.getSnowmanPattern().getThumbLength(); ++i1)
        {
            BlockWorldState blockworldstate1 = blockpattern$patternhelper.translateOffset(0, i1, 0);
            worldIn.notifyNeighborsRespectDebug(blockworldstate1.getPos(), Blocks.air);
        }
    }
    else if ((blockpattern$patternhelper = this.getGolemPattern().match(worldIn, pos)) != null)
    {
        for (int k = 0; k < this.getGolemPattern().getPalmLength(); ++k)
        {
            for (int l = 0; l < this.getGolemPattern().getThumbLength(); ++l)
            {
                worldIn.setBlockState(blockpattern$patternhelper.translateOffset(k, l, 0).getPos(), Blocks.air.getDefaultState(), 2);
            }
        }

        BlockPos blockpos = blockpattern$patternhelper.translateOffset(1, 2, 0).getPos();
        EntityIronGolem entityirongolem = new EntityIronGolem(worldIn);
        entityirongolem.setPlayerCreated(true);
        entityirongolem.setLocationAndAngles((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.05D, (double)blockpos.getZ() + 0.5D, 0.0F, 0.0F);
        worldIn.spawnEntityInWorld(entityirongolem);

        for (int j1 = 0; j1 < 120; ++j1)
        {
            worldIn.spawnParticle(EnumParticleTypes.SNOWBALL, (double)blockpos.getX() + worldIn.rand.nextDouble(), (double)blockpos.getY() + worldIn.rand.nextDouble() * 3.9D, (double)blockpos.getZ() + worldIn.rand.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]);
        }

        for (int k1 = 0; k1 < this.getGolemPattern().getPalmLength(); ++k1)
        {
            for (int l1 = 0; l1 < this.getGolemPattern().getThumbLength(); ++l1)
            {
                BlockWorldState blockworldstate2 = blockpattern$patternhelper.translateOffset(k1, l1, 0);
                worldIn.notifyNeighborsRespectDebug(blockworldstate2.getPos(), Blocks.air);
            }
        }
    }
}