Java 类net.minecraft.block.BlockChorusFlower 实例源码
项目:EnderIO
文件:ChorusFarmer.java
@Override
public boolean prepareBlock(@Nonnull IFarmer farm, @Nonnull BlockPos pos, @Nonnull Block block, @Nonnull IBlockState state) {
final ItemStack seed = farm.getSeedTypeInSuppliesFor(pos);
final EntityPlayerMP player = farm.getFakePlayer();
final World world = farm.getWorld();
if (canPlant(seed) && isValidPlantingSpot(world, pos) && player.canPlayerEdit(pos, EnumFacing.UP, seed)
&& world.mayPlace(Blocks.CHORUS_FLOWER, pos, false, EnumFacing.UP, (Entity) null)) {
IBlockState iblockstate1 = Blocks.CHORUS_FLOWER.getDefaultState().withProperty(BlockChorusFlower.AGE, 0);
IBlockState oldState = world.getBlockState(pos);
if (placeBlockAt(seed, player, world, pos, iblockstate1)) {
if (Prep.isValid(farm.takeSeedFromSupplies(pos))) {
SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player);
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
return true;
} else {
world.setBlockState(pos, oldState, 3);
}
}
}
return false;
}
项目:EnderIO
文件:ChorusFarmer.java
boolean collect(@Nonnull BlockPos pos, @Nonnull EnumFacing from) {
IBlockState state = farm.getWorld().getBlockState(pos);
if (state.getBlock() == Blocks.CHORUS_PLANT) {
boolean isNeeded = false;
NNIterator<EnumFacing> iterator = GROW_DIRECTIONS.iterator();
while (iterator.hasNext()) {
EnumFacing side = iterator.next();
if (side != from) {
isNeeded |= collect(pos.offset(side), side.getOpposite());
}
}
if (!isNeeded) {
stemsToHarvest.add(pos);
}
return isNeeded;
} else if (state.getBlock() == Blocks.CHORUS_FLOWER) {
if (state.getValue(BlockChorusFlower.AGE) == 5) {
flowersToHarvest.add(pos);
return false;
}
return true;
}
return false;
}
项目:Backmemed
文件:ChunkProviderEnd.java
public void populate(int x, int z)
{
BlockFalling.fallInstantly = true;
BlockPos blockpos = new BlockPos(x * 16, 0, z * 16);
if (this.mapFeaturesEnabled)
{
this.endCityGen.generateStructure(this.worldObj, this.rand, new ChunkPos(x, z));
}
this.worldObj.getBiome(blockpos.add(16, 0, 16)).decorate(this.worldObj, this.worldObj.rand, blockpos);
long i = (long)x * (long)x + (long)z * (long)z;
if (i > 4096L)
{
float f = this.getIslandHeightValue(x, z, 1, 1);
if (f < -20.0F && this.rand.nextInt(14) == 0)
{
this.endIslands.generate(this.worldObj, this.rand, blockpos.add(this.rand.nextInt(16) + 8, 55 + this.rand.nextInt(16), this.rand.nextInt(16) + 8));
if (this.rand.nextInt(4) == 0)
{
this.endIslands.generate(this.worldObj, this.rand, blockpos.add(this.rand.nextInt(16) + 8, 55 + this.rand.nextInt(16), this.rand.nextInt(16) + 8));
}
}
if (this.getIslandHeightValue(x, z, 1, 1) > 40.0F)
{
int j = this.rand.nextInt(5);
for (int k = 0; k < j; ++k)
{
int l = this.rand.nextInt(16) + 8;
int i1 = this.rand.nextInt(16) + 8;
int j1 = this.worldObj.getHeight(blockpos.add(l, 0, i1)).getY();
if (j1 > 0)
{
int k1 = j1 - 1;
if (this.worldObj.isAirBlock(blockpos.add(l, k1 + 1, i1)) && this.worldObj.getBlockState(blockpos.add(l, k1, i1)).getBlock() == Blocks.END_STONE)
{
BlockChorusFlower.generatePlant(this.worldObj, blockpos.add(l, k1 + 1, i1), this.rand, 8);
}
}
}
if (this.rand.nextInt(700) == 0)
{
int l1 = this.rand.nextInt(16) + 8;
int i2 = this.rand.nextInt(16) + 8;
int j2 = this.worldObj.getHeight(blockpos.add(l1, 0, i2)).getY();
if (j2 > 0)
{
int k2 = j2 + 3 + this.rand.nextInt(7);
BlockPos blockpos1 = blockpos.add(l1, k2, i2);
(new WorldGenEndGateway()).generate(this.worldObj, this.rand, blockpos1);
TileEntity tileentity = this.worldObj.getTileEntity(blockpos1);
if (tileentity instanceof TileEntityEndGateway)
{
TileEntityEndGateway tileentityendgateway = (TileEntityEndGateway)tileentity;
tileentityendgateway.func_190603_b(this.field_191061_n);
}
}
}
}
}
BlockFalling.fallInstantly = false;
}
项目:CustomWorldGen
文件:ChunkProviderEnd.java
public void populate(int x, int z)
{
BlockFalling.fallInstantly = true;
net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(true, this, this.worldObj, this.rand, x, z, false);
BlockPos blockpos = new BlockPos(x * 16, 0, z * 16);
if (this.mapFeaturesEnabled)
{
this.endCityGen.generateStructure(this.worldObj, this.rand, new ChunkPos(x, z));
}
this.worldObj.getBiome(blockpos.add(16, 0, 16)).decorate(this.worldObj, this.worldObj.rand, blockpos);
long i = (long)x * (long)x + (long)z * (long)z;
if (i > 4096L)
{
float f = this.getIslandHeightValue(x, z, 1, 1);
if (f < -20.0F && this.rand.nextInt(14) == 0)
{
this.endIslands.generate(this.worldObj, this.rand, blockpos.add(this.rand.nextInt(16) + 8, 55 + this.rand.nextInt(16), this.rand.nextInt(16) + 8));
if (this.rand.nextInt(4) == 0)
{
this.endIslands.generate(this.worldObj, this.rand, blockpos.add(this.rand.nextInt(16) + 8, 55 + this.rand.nextInt(16), this.rand.nextInt(16) + 8));
}
}
if (this.getIslandHeightValue(x, z, 1, 1) > 40.0F)
{
int j = this.rand.nextInt(5);
for (int k = 0; k < j; ++k)
{
int l = this.rand.nextInt(16) + 8;
int i1 = this.rand.nextInt(16) + 8;
int j1 = this.worldObj.getHeight(blockpos.add(l, 0, i1)).getY();
if (j1 > 0)
{
int k1 = j1 - 1;
if (this.worldObj.isAirBlock(blockpos.add(l, k1 + 1, i1)) && this.worldObj.getBlockState(blockpos.add(l, k1, i1)).getBlock() == Blocks.END_STONE)
{
BlockChorusFlower.generatePlant(this.worldObj, blockpos.add(l, k1 + 1, i1), this.rand, 8);
}
}
}
}
}
net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.worldObj, this.rand, x, z, false);
BlockFalling.fallInstantly = false;
}