net.minecraft.block.BlockFalling Java Examples

The following examples show how to use net.minecraft.block.BlockFalling. 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: BlockGravity.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
protected void fall(World worldIn, BlockPos pos, IBlockState state)
{
	int i = 32;

	if ((!BlockFalling.fallInstantly) && (worldIn.isAreaLoaded(pos.add(-i, -i, -i), pos.add(i, i, i))))
	{
		if (!worldIn.isRemote)
		{
			EntityFallingBlockTFC entityfallingblock = new EntityFallingBlockTFC(worldIn, pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D, state);
			onStartFalling(entityfallingblock);
			worldIn.spawnEntity(entityfallingblock);
		}
	}
	else
	{
		((World)worldIn).setBlockToAir(pos);

		BlockPos blockpos;
		for (blockpos = pos.down(); (canFallInto(worldIn, blockpos)) && (blockpos.getY() > 0); blockpos = blockpos.down()) {}

		if (blockpos.getY() > 0)
		{
			worldIn.setBlockState(blockpos.up(), getDefaultState());
		}
	}
}
 
Example #2
Source File: ChunkProviderTofu.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@Override
public void populate(int x, int z) {
    BlockFalling.fallInstantly = true;
    BlockPos blockpos = new BlockPos(x * 16, 0, z * 16);

    Biome biome = this.world.getBiome(blockpos.add(16, 0, 16));

    rand.setSeed(world.getSeed());
    long xSeed = rand.nextLong() / 2L * 2L + 1L;
    long zSeed = rand.nextLong() / 2L * 2L + 1L;
    rand.setSeed(chunkX * xSeed + chunkZ * zSeed ^ world.getSeed());

    int i = x * 16;
    int j = z * 16;

    if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(this.world, this.rand, diamondGen, blockpos, OreGenEvent.GenerateMinable.EventType.CUSTOM))
        for (int l1 = 0; l1 < 12; ++l1)
        {
            this.diamondGen.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16), this.rand.nextInt(30), this.rand.nextInt(16)));
        }


    ChunkPos chunkpos = new ChunkPos(x, z);

    if (mapFeaturesEnabled) {
        this.mineshaft.generateStructure(this.world, this.rand, chunkpos);
        this.villageGenerator.generateStructure(this.world, this.rand, chunkpos);
        this.tofuCastle.generateStructure(this.world, this.rand, chunkpos);
    }

    biome.decorate(world, rand, blockpos);


    if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.world, this.rand, x, z, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ANIMALS))
        WorldEntitySpawner.performWorldGenSpawning(this.world, biome, i + 8, j + 8, 16, 16, this.rand);

    net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.world, this.rand, x, z, false);

    BlockFalling.fallInstantly = false;
}
 
Example #3
Source File: ChunkProviderRoss128ba.java    From bartworks with MIT License 5 votes vote down vote up
@Override
public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) {
    super.populate(par1IChunkProvider, par2, par3);
    BlockFalling.fallInstantly = true;
    ChunkProviderRoss128b.BWOreGen.generate(this.rand, par2, par3, this.worldObj, this, this);
    BlockFalling.fallInstantly = false;
}
 
Example #4
Source File: TunnellerHack.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
private boolean equipSolidBlock(BlockPos pos)
{
	for(int slot = 0; slot < 9; slot++)
	{
		// filter out non-block items
		ItemStack stack =
			WMinecraft.getPlayer().inventory.getStackInSlot(slot);
		if(WItem.isNullOrEmpty(stack)
			|| !(stack.getItem() instanceof ItemBlock))
			continue;
		
		Block block = Block.getBlockFromItem(stack.getItem());
		
		// filter out non-solid blocks
		if(!block.getDefaultState().isFullBlock())
			continue;
		
		// filter out blocks that would fall
		if(block instanceof BlockFalling && BlockFalling
			.canFallThrough(BlockUtils.getState(pos.down())))
			continue;
		
		WMinecraft.getPlayer().inventory.currentItem = slot;
		return true;
	}
	
	return false;
}
 
Example #5
Source File: BlockValkyriumOre.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
private void tryFallingUp(World worldIn, BlockPos pos) {
    BlockPos downPos = pos.up();
    if ((worldIn.isAirBlock(downPos) || canFallThrough(worldIn.getBlockState(downPos)))
        && pos.getY() >= 0) {
        int i = 32;

        if (!BlockFalling.fallInstantly && worldIn
            .isAreaLoaded(pos.add(-32, -32, -32), pos.add(32, 32, 32))) {
            if (!worldIn.isRemote) {
                // Start falling up
                EntityFallingUpBlock entityfallingblock = new EntityFallingUpBlock(worldIn,
                    (double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D,
                    worldIn.getBlockState(pos));
                worldIn.spawnEntity(entityfallingblock);
            }
        } else {
            IBlockState state = worldIn.getBlockState(pos);
            worldIn.setBlockToAir(pos);
            BlockPos blockpos;

            for (blockpos = pos.up(); (worldIn.isAirBlock(blockpos) || canFallThrough(
                worldIn.getBlockState(blockpos))) && blockpos.getY() < 255;
                blockpos = blockpos.up()) {
            }

            if (blockpos.getY() < 255) {
                worldIn.setBlockState(blockpos.down(), state, 3);
            }
        }
    }
}
 
Example #6
Source File: SchematicBlock.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BuildingStage getBuildStage () {
	if (block instanceof BlockFalling) {
		return BuildingStage.SUPPORTED;
	} else if (block instanceof BlockFluidBase || block instanceof BlockLiquid) {
		return BuildingStage.EXPANDING;
	} else if (block.isOpaqueCube()) {
		return BuildingStage.STANDALONE;
	} else {
		return BuildingStage.SUPPORTED;
	}
}
 
Example #7
Source File: ChunkProviderRoss128b.java    From bartworks with MIT License 4 votes vote down vote up
@Override
public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) {
    BlockFalling.fallInstantly = true;
    int k = p_73153_2_ * 16;
    int l = p_73153_3_ * 16;
    BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(k + 16, l + 16);
    this.rand.setSeed(this.worldObj.getSeed());
    if (p_73153_2_ % 4 == 0 || p_73153_3_ % 4 == 0) {
        long i1 = this.rand.nextLong() / 2L * 2L + 1L;
        long j1 = this.rand.nextLong() / 2L * 2L + 1L;
        this.rand.setSeed((long) p_73153_2_ * i1 + (long) p_73153_3_ * j1 ^ this.worldObj.getSeed());
    }

    MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false));

    int x1;
    int y1;
    int z1;
    if (biomegenbase != BiomeGenBase.desert && biomegenbase != BiomeGenBase.desertHills && TerrainGen.populate(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false, LAKE)) {
        x1 = k + this.rand.nextInt(16) + 8;
        y1 = this.rand.nextInt(256);
        z1 = l + this.rand.nextInt(16) + 8;
        int rni = this.rand.nextInt(8);
        if (rni == 0)
            (new WorldGenLakes(Blocks.ice)).generate(this.worldObj, this.rand, x1, y1, z1);
        else if (rni == 4)
            (new WorldGenLakes(Blocks.water)).generate(this.worldObj, this.rand, x1, y1, z1);
    }
    if (biomegenbase != BiomeGenBase.ocean && biomegenbase != BiomeGenBase.deepOcean && biomegenbase != BiomeGenBase.river && biomegenbase != BiomeGenBase.frozenOcean && biomegenbase != BiomeGenBase.frozenRiver
            && this.rand.nextInt(ConfigHandler.ross128bRuinChance) == 0) {
        x1 = k + this.rand.nextInt(16) + 3;
        y1 = this.rand.nextInt(256);
        z1 = l + this.rand.nextInt(16) + 3;
        this.ruinsBase.generate(this.worldObj, this.rand, x1, y1, z1);
    }

    biomegenbase.decorate(this.worldObj, this.rand, k, l);

    k += 8;
    l += 8;

    boolean doGen = TerrainGen.populate(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false, ICE);
    for (x1 = 0; doGen && x1 < 16; ++x1) {
        for (y1 = 0; y1 < 16; ++y1) {
            z1 = this.worldObj.getPrecipitationHeight(k + x1, l + y1);

            if (this.worldObj.isBlockFreezable(x1 + k, z1 - 1, y1 + l)) {
                this.worldObj.setBlock(x1 + k, z1 - 1, y1 + l, Blocks.ice, 0, 2);
            }

            if (this.worldObj.func_147478_e(x1 + k, z1, y1 + l, true)) {
                this.worldObj.setBlock(x1 + k, z1, y1 + l, Blocks.snow_layer, 0, 2);
            }
        }
    }

    BWOreGen.generate(this.rand, p_73153_2_, p_73153_3_, this.worldObj, this, this);
    MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false));

    BlockFalling.fallInstantly = false;
}
 
Example #8
Source File: SpongeQueue_1_11.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public boolean regenerateChunk(net.minecraft.world.World world, int x, int z) {
    IChunkProvider provider = world.getChunkProvider();
    if (!(provider instanceof ChunkProviderServer)) {
        return false;
    }
    BlockFalling.fallInstantly = true;
    try {
        ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
        IChunkGenerator gen = (IChunkGenerator) fieldChunkGenerator.get(chunkServer);
        long pos = ChunkPos.asLong(x, z);
        Chunk mcChunk;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            mcChunk.onChunkUnload();
        }
        PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap();
        List<EntityPlayerMP> oldWatchers = null;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            PlayerChunkMapEntry entry = playerManager.getEntry(x, z);
            if (entry != null) {
                Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c");
                fieldPlayers.setAccessible(true);
                oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry);
                playerManager.removeEntry(entry);
            }
            mcChunk.onChunkUnload();
        }
        try {
            Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b");
            droppedChunksSetField.setAccessible(true);
            Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer);
            droppedChunksSet.remove(pos);
        } catch (Throwable e) {
            MainUtil.handleError(e);
        }
        Long2ObjectMap<Chunk> id2ChunkMap = (Long2ObjectMap<Chunk>) fieldId2ChunkMap.get(chunkServer);
        id2ChunkMap.remove(pos);
        mcChunk = gen.provideChunk(x, z);
        id2ChunkMap.put(pos, mcChunk);
        if (mcChunk != null) {
            mcChunk.onChunkLoad();
            mcChunk.populateChunk(chunkServer, gen);
        }
        if (oldWatchers != null) {
            for (EntityPlayerMP player : oldWatchers) {
                playerManager.addPlayer(player);
            }
        }
        return true;
    } catch (Throwable t) {
        MainUtil.handleError(t);
        return false;
    } finally {
        BlockFalling.fallInstantly = false;
    }
}
 
Example #9
Source File: SpongeQueue_1_12.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public boolean regenerateChunk(net.minecraft.world.World world, int x, int z) {
    IChunkProvider provider = world.getChunkProvider();
    if (!(provider instanceof ChunkProviderServer)) {
        return false;
    }
    BlockFalling.fallInstantly = true;
    try {
        ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
        IChunkGenerator gen = (IChunkGenerator) fieldChunkGenerator.get(chunkServer);
        long pos = ChunkPos.asLong(x, z);
        Chunk mcChunk;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            mcChunk.onUnload();
        }
        PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap();
        List<EntityPlayerMP> oldWatchers = null;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            PlayerChunkMapEntry entry = playerManager.getEntry(x, z);
            if (entry != null) {
                Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c");
                fieldPlayers.setAccessible(true);
                oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry);
                playerManager.removeEntry(entry);
            }
            mcChunk.onUnload();
        }
        try {
            Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b");
            droppedChunksSetField.setAccessible(true);
            Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer);
            droppedChunksSet.remove(pos);
        } catch (Throwable e) {
            MainUtil.handleError(e);
        }
        Long2ObjectMap<Chunk> id2ChunkMap = (Long2ObjectMap<Chunk>) fieldId2ChunkMap.get(chunkServer);
        id2ChunkMap.remove(pos);
        mcChunk = gen.generateChunk(x, z);
        id2ChunkMap.put(pos, mcChunk);
        if (mcChunk != null) {
            mcChunk.onLoad();
            mcChunk.populate(chunkServer, gen);
        }
        if (oldWatchers != null) {
            for (EntityPlayerMP player : oldWatchers) {
                playerManager.addPlayer(player);
            }
        }
        return true;
    } catch (Throwable t) {
        MainUtil.handleError(t);
        return false;
    } finally {
        BlockFalling.fallInstantly = false;
    }
}
 
Example #10
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public boolean regenerateChunk(World world, int x, int z) {
    IChunkProvider provider = world.getChunkProvider();
    if (!(provider instanceof ChunkProviderServer)) {
        return false;
    }
    BlockFalling.fallInstantly = true;
    try {
        ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
        IChunkGenerator gen = (IChunkGenerator) fieldChunkGenerator.get(chunkServer);
        long pos = ChunkPos.asLong(x, z);
        Chunk mcChunk;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            mcChunk.onUnload();
        }
        PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap();
        List<EntityPlayerMP> oldWatchers = null;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            PlayerChunkMapEntry entry = playerManager.getEntry(x, z);
            if (entry != null) {
                Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c");
                fieldPlayers.setAccessible(true);
                oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry);
                playerManager.removeEntry(entry);
            }
            mcChunk.onUnload();
        }
        try {
            Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b");
            droppedChunksSetField.setAccessible(true);
            Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer);
            droppedChunksSet.remove(pos);
        } catch (Throwable e) {
            MainUtil.handleError(e);
        }
        Long2ObjectMap<Chunk> id2ChunkMap = chunkServer.id2ChunkMap;
        id2ChunkMap.remove(pos);
        mcChunk = gen.generateChunk(x, z);
        id2ChunkMap.put(pos, mcChunk);
        if (mcChunk != null) {
            mcChunk.onLoad();
            mcChunk.populate(chunkServer, gen);
        }
        if (oldWatchers != null) {
            for (EntityPlayerMP player : oldWatchers) {
                playerManager.addPlayer(player);
            }
        }
        return true;
    } catch (Throwable t) {
        MainUtil.handleError(t);
        return false;
    } finally {
        BlockFalling.fallInstantly = false;
    }
}
 
Example #11
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public boolean regenerateChunk(World world, int x, int z) {
    IChunkProvider provider = world.getChunkProvider();
    if (!(provider instanceof ChunkProviderServer)) {
        return false;
    }
    BlockFalling.fallInstantly = true;
    try {
        ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
        IChunkGenerator gen = chunkServer.chunkGenerator;
        long pos = ChunkPos.asLong(x, z);
        Chunk mcChunk;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            mcChunk.onChunkUnload();
        }
        PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap();
        List<EntityPlayerMP> oldWatchers = null;
        if (chunkServer.chunkExists(x, z)) {
            mcChunk = chunkServer.loadChunk(x, z);
            PlayerChunkMapEntry entry = playerManager.getEntry(x, z);
            if (entry != null) {
                Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c");
                fieldPlayers.setAccessible(true);
                oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry);
                playerManager.removeEntry(entry);
            }
            mcChunk.onChunkUnload();
        }
        try {
            Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b");
            droppedChunksSetField.setAccessible(true);
            Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer);
            droppedChunksSet.remove(pos);
        } catch (Throwable e) {
            MainUtil.handleError(e);
        }
        chunkServer.id2ChunkMap.remove(pos);
        mcChunk = gen.provideChunk(x, z);
        chunkServer.id2ChunkMap.put(pos, mcChunk);
        if (mcChunk != null) {
            mcChunk.onChunkLoad();
            mcChunk.populateChunk(chunkServer, chunkServer.chunkGenerator);
        }
        if (oldWatchers != null) {
            for (EntityPlayerMP player : oldWatchers) {
                playerManager.addPlayer(player);
            }
        }
        return true;
    } catch (Throwable t) {
        MainUtil.handleError(t);
        return false;
    } finally {
        BlockFalling.fallInstantly = false;
    }
}