本文整理汇总了Java中net.minecraft.block.BlockGrass类的典型用法代码示例。如果您正苦于以下问题:Java BlockGrass类的具体用法?Java BlockGrass怎么用?Java BlockGrass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlockGrass类属于net.minecraft.block包,在下文中一共展示了BlockGrass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import net.minecraft.block.BlockGrass; //导入依赖的package包/类
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
IChunkProvider chunkProvider) {
if (random.nextInt(20) == 0){
int x = chunkX * 16 + 2 + random.nextInt(12);
int z = chunkZ * 16 + 2 + random.nextInt(12);
BlockPos p = new BlockPos(x,0,z);
p = world.getHeight(p);
Biome b = world.getBiome(p);
if (BiomeDictionary.hasType(b, BiomeDictionary.Type.FOREST) || b == Biomes.FOREST || b == Biomes.FOREST_HILLS){
if (world.getBlockState(p.down()).getBlock() instanceof BlockGrass && world.isAirBlock(p)){
BlockTeaSapling.generateTree(world, p, Blocks.AIR.getDefaultState(), random);
}
}
}
}
示例2: isCorrectBlock
import net.minecraft.block.BlockGrass; //导入依赖的package包/类
private boolean isCorrectBlock(BlockPos pos)
{
Block block = WBlock.getBlock(pos);
if(!(block instanceof IGrowable) || block instanceof BlockGrass
|| !((IGrowable)block).canGrow(WMinecraft.getWorld(), pos,
WBlock.getState(pos), false))
return false;
if(block instanceof BlockSapling)
return saplings.isChecked();
else if(block instanceof BlockCrops)
return crops.isChecked();
else if(block instanceof BlockStem)
return stems.isChecked();
else if(block instanceof BlockCocoa)
return cocoa.isChecked();
else
return other.isChecked();
}
示例3: applyBonemeal
import net.minecraft.block.BlockGrass; //导入依赖的package包/类
public static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, @javax.annotation.Nullable EnumHand hand) {
if (!(state.getBlock() instanceof BlockGrass) || player.isSneaking()) {
int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, worldIn, pos, state, stack, hand);
if (hook != 0) return hook > 0;
IGrowable igrowable = (IGrowable) state.getBlock();
if (igrowable.canGrow(worldIn, pos, state, worldIn.isRemote)) {
if (!worldIn.isRemote) {
if (igrowable.canUseBonemeal(worldIn, worldIn.rand, pos, state)) {
igrowable.grow(worldIn, worldIn.rand, pos, state);
}
stack.damageItem(1, player);
}
return true;
}
}
return false;
}
示例4: placeGrass
import net.minecraft.block.BlockGrass; //导入依赖的package包/类
void placeGrass(World world, BlockPos pos, Random random, int fertility) {
Block block = world.getBlockState(pos.down()).getBlock();
if (block instanceof BlockGrass && block.canPlaceBlockAt(world, pos)) {
if (fertility < 50 && random.nextInt(15) == 0) {
world.setBlockState(pos, Blocks.tallgrass.getDefaultState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.DEAD_BUSH), 2);
return;
}
if (fertility > 200 && random.nextInt(3) == 0) {
if (random.nextInt(20) == 0) {
if (random.nextBoolean()) {
world.setBlockState(pos, Blocks.brown_mushroom.getDefaultState());
} else {
world.setBlockState(pos, Blocks.red_mushroom.getDefaultState());
}
return;
}
world.setBlockState(pos, Blocks.tallgrass.getDefaultState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.FERN), 2);
return;
}
world.setBlockState(pos, Blocks.tallgrass.getDefaultState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.GRASS), 2);
}
}
示例5: generate
import net.minecraft.block.BlockGrass; //导入依赖的package包/类
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{
if (world.provider.getDimensionId() == 0)
{
for (int i = 0; i < 4; i++)
{
int x = chunkX * 16 + random.nextInt(16);
int z = chunkZ * 16 + random.nextInt(16);
BlockPos pos = world.getHorizon(new BlockPos(x, 0, z));
if (world.getBlockState(pos.down()).getBlock() instanceof BlockGrass)
{
world.setBlockState(pos, ARKCraftBlocks.berryBush.getDefaultState());
}
}
}
}
示例6: onUseHoe
import net.minecraft.block.BlockGrass; //导入依赖的package包/类
@SubscribeEvent
public void onUseHoe(UseHoeEvent event) {
Block oblock = event.world.getBlock(event.x, event.y, event.z);
if (LongHoe.AOEEnabled && event.current.getItem() instanceof LongHoe && (oblock instanceof BlockDirt || oblock instanceof BlockGrass)) {
LongHoe.AOEEnabled = false;
for (int x = event.x - 3; x < event.x + 3; x++) {
for (int z = event.z - 3; z < event.z + 3; z++) {
Block block = event.world.getBlock(x, event.y, z);
if ((!(x == event.x && z == event.z)) && (block instanceof BlockDirt || block instanceof BlockGrass) && (!MinecraftForge.EVENT_BUS.post(new UseHoeEvent(event.entityPlayer, event.current, event.world, x, event.y, z)))) {
event.world.setBlock(x, event.y, z, Blocks.farmland);
if (event.world.getBlock(x, event.y + 1, z).isReplaceable(event.world, x, event.y + 1, z)) {
event.world.setBlockToAir(x, event.y + 1, z);
}
DerpyItems.damageItem(event.current, 1, event.entityPlayer);
}
}
}
LongHoe.AOEEnabled = true;
}
}
示例7: getBlockColor
import net.minecraft.block.BlockGrass; //导入依赖的package包/类
/**
* Returns a integer with hex for 0xrrggbb for block. Color is most
* commonly different for {@link Blocks#grass}
* <p>
* If using our custom render helpers, be sure to use {@link #applyAnaglyph(float[])}.
*
* @param itemStack the cover {@link ItemStack}
* @param block the {@link Block} inside the {@link ItemStack}
* @param x the x coordinate
* @param y the y coordinate
* @param z the z coordinate
* @return a integer with hex for 0xrrggbb
*/
public int getBlockColor(Block block, int metadata, int x, int y, int z, int side, IIcon icon)
{
if (block.hasTileEntity(metadata)) {
block = Blocks.dirt;
}
TE.setMetadata(metadata);
int color = OptifineHandler.enableOptifineIntegration ? OptifineHandler.getColorMultiplier(block, TE.getWorldObj(), x, y, z) : block.colorMultiplier(TE.getWorldObj(), x, y, z);
TE.restoreMetadata();
if (block.equals(Blocks.grass) && !isPositiveFace(side) && !icon.equals(BlockGrass.getIconSideOverlay())) {
color = 16777215;
}
return color;
}
示例8: getFaceQuads
import net.minecraft.block.BlockGrass; //导入依赖的package包/类
public static List getFaceQuads(IBlockAccess p_getFaceQuads_0_, IBlockState p_getFaceQuads_1_, BlockPos p_getFaceQuads_2_, EnumFacing p_getFaceQuads_3_, List p_getFaceQuads_4_)
{
if (p_getFaceQuads_3_ != EnumFacing.UP && p_getFaceQuads_3_ != EnumFacing.DOWN)
{
Block block = p_getFaceQuads_1_.getBlock();
return block instanceof BlockMycelium ? getFaceQuadsMycelium(p_getFaceQuads_0_, p_getFaceQuads_1_, p_getFaceQuads_2_, p_getFaceQuads_3_, p_getFaceQuads_4_) : (block instanceof BlockGrassPath ? getFaceQuadsGrassPath(p_getFaceQuads_0_, p_getFaceQuads_1_, p_getFaceQuads_2_, p_getFaceQuads_3_, p_getFaceQuads_4_) : (block instanceof BlockDirt ? getFaceQuadsDirt(p_getFaceQuads_0_, p_getFaceQuads_1_, p_getFaceQuads_2_, p_getFaceQuads_3_, p_getFaceQuads_4_) : (block instanceof BlockGrass ? getFaceQuadsGrass(p_getFaceQuads_0_, p_getFaceQuads_1_, p_getFaceQuads_2_, p_getFaceQuads_3_, p_getFaceQuads_4_) : p_getFaceQuads_4_)));
}
else
{
return p_getFaceQuads_4_;
}
}
示例9: caveableBlock
import net.minecraft.block.BlockGrass; //导入依赖的package包/类
protected boolean caveableBlock(IBlockState blockstate, IBlockState aboveblockstate) {
if (aboveblockstate.getBlock().getMaterial() == Material.water) return false;
return
blockstate.getBlock() instanceof BlockStone
|| blockstate.getBlock() instanceof BlockDirt
|| blockstate.getBlock() instanceof BlockGrass
;
}
示例10: setLawn
import net.minecraft.block.BlockGrass; //导入依赖的package包/类
public void setLawn(final World world, final int x, final int y, final int z, final EntityLivingBase entity) {
final Block block = world.getBlock(x, y, z);
if(block instanceof BlockGrass || block instanceof Lawn) {
final int i = MathHelper
.floor_double((double) ((entity.rotationYaw * 4F) / 360F) + 0.5D) & 3;
world.setBlock(x, y, z, BlockManager.lawn, dirMap[i], 2);
world.markBlockForUpdate(x, y, z);
}
}
示例11: renderSide
import net.minecraft.block.BlockGrass; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@Override
public boolean renderSide(Vertex5[] verts, int side, Vector3 pos,
LightMatrix lightMatrix, int color, Cuboid6 bounds) {
if (grass.isTop(side)) {
Tessellator.instance.setColorOpaque_I(color >> 8);
grass.renderSide(verts, side, pos, lightMatrix, color, bounds);
} else {
Tessellator.instance.setColorOpaque_I(0xFFFFFFFF >> 8);
dirt.renderSide(verts, side, pos, lightMatrix, 0xFFFFFFFF, bounds);
if (dirt.isSide(side)) {
//dummy.renderSide(verts, side, pos, lightMatrix, color);
Tessellator.instance.setColorOpaque_I(color >> 8);
IIcon temp = grass.getBoundIcon();
grass.setBoundIcon(BlockGrass.getIconSideOverlay());
if (bounds != null) {
for (int i = 0; i < 4; i++) {
verts[i].uv.v -= 1 - bounds.max.y;
}
}
grass.renderSide(verts, side, pos, lightMatrix, color, bounds);
grass.setBoundIcon(temp);
}
}
return true;
}
示例12: onBlockHarvest
import net.minecraft.block.BlockGrass; //导入依赖的package包/类
@SubscribeEvent
public void onBlockHarvest(HarvestDropsEvent event) {
if (!Config.direSlimeEnabled || event.isCanceled() || event.getWorld() == null || event.getWorld().isRemote) {
return;
}
if (event.getHarvester() == null || event.getHarvester().capabilities.isCreativeMode) {
return;
}
if (!(event.getState().getBlock() instanceof BlockDirt || event.getState().getBlock() instanceof BlockGrass)) {
return;
}
if (!isToolEffective(event.getState(), event.getHarvester().getHeldItemMainhand())) {
if (Config.direSlimeChance < event.getWorld().rand.nextFloat()) {
return;
}
EntityDireSlime direSlime = new EntityDireSlime(event.getWorld());
direSlime.setPosition(event.getPos().getX() + 0.5, event.getPos().getY() + 0.0, event.getPos().getZ() + 0.5);
event.getWorld().spawnEntity(direSlime);
direSlime.playLivingSound();
for (ItemStack drop : event.getDrops()) {
if (drop != null && drop.getItem() != null && drop.getItem() == Item.getItemFromBlock(Blocks.DIRT)) {
if (drop.getCount() > 1) {
drop.shrink(1);
} else if (event.getDrops().size() == 1) {
event.getDrops().clear();
} else {
event.getDrops().remove(drop);
}
return;
}
}
}
}
示例13: onFertilization
import net.minecraft.block.BlockGrass; //导入依赖的package包/类
@SubscribeEvent
public void onFertilization(BonemealEvent event){
if(event.world.isRemote) return; // why would we want to handle this on the client-side?
if(event.block == Blocks.netherrack || event.block == Blocks.end_stone || event.block.canSustainPlant(event.world, event.x, event.y, event.z, ForgeDirection.UP, Blocks.red_flower)) { // can bonemeal Biomes O' Plenty grass, etc.
boolean onGrass = event.block instanceof BlockGrass;
if(onGrass && Config.includePlantsOnBonemeal || !onGrass && Config.allowDirtBonemealing) {
// we'll try to spawn plants in a 5x5 area which is centered on the block that has been bonemealed
for(int x = event.x - 2; x < event.x + 3; x++) {
for(int z = event.z - 2; z < event.z + 3; z++) {
if(event.world.isAirBlock(x, event.y + 1, z)) {
if(event.world.rand.nextInt(8) == 1) { // increase .nextInt(x) to lower the chances of spawning a plant
BlockPneumaticPlantBase trySpawn = BlockPlants.allPlants.get(event.world.rand.nextInt(BlockPlants.allPlants.size() - 1)); // select a random plant
if(trySpawn.canPlantGrowOnThisBlock(event.world.getBlock(x, event.y, z), event.world, x, event.y, z)) { // make sure that the plant we selected can grow on the soil
event.world.setBlock(x, event.y + (trySpawn.isPlantHanging() ? -1 : 1), z, trySpawn);
}
}
}
}
/*
* vanilla mechanics will spawn flowers etc. when bonemeal is used on grass,
* so we cannot set Result.ALLOW in this case because it would stop event-propagation
*/
if(!onGrass) event.setResult(Result.ALLOW);
}
}
}
}
示例14: shouldBlockBeChanged
import net.minecraft.block.BlockGrass; //导入依赖的package包/类
private boolean shouldBlockBeChanged(IBlockState state)
{
return state.getBlock() instanceof BlockDirt ||
state.getBlock() instanceof BlockGrass ||
state.getBlock() instanceof BlockLeaves;
}
示例15: getFaceQuads
import net.minecraft.block.BlockGrass; //导入依赖的package包/类
public static List getFaceQuads(IBlockAccess p_getFaceQuads_0_, Block p_getFaceQuads_1_, BlockPos p_getFaceQuads_2_, EnumFacing p_getFaceQuads_3_, List p_getFaceQuads_4_)
{
if (p_getFaceQuads_3_ != EnumFacing.UP && p_getFaceQuads_3_ != EnumFacing.DOWN)
{
if (p_getFaceQuads_1_ instanceof BlockMycelium)
{
return Config.isBetterGrassFancy() ? (getBlockAt(p_getFaceQuads_2_.down(), p_getFaceQuads_3_, p_getFaceQuads_0_) == Blocks.mycelium ? modelCubeMycelium.getFaceQuads(p_getFaceQuads_3_) : p_getFaceQuads_4_) : modelCubeMycelium.getFaceQuads(p_getFaceQuads_3_);
}
else
{
if (p_getFaceQuads_1_ instanceof BlockGrass)
{
Block block = p_getFaceQuads_0_.getBlockState(p_getFaceQuads_2_.up()).getBlock();
boolean flag = block == Blocks.snow || block == Blocks.snow_layer;
if (!Config.isBetterGrassFancy())
{
if (flag)
{
return modelCubeGrassSnowy.getFaceQuads(p_getFaceQuads_3_);
}
return modelCubeGrass.getFaceQuads(p_getFaceQuads_3_);
}
if (flag)
{
if (getBlockAt(p_getFaceQuads_2_, p_getFaceQuads_3_, p_getFaceQuads_0_) == Blocks.snow_layer)
{
return modelCubeGrassSnowy.getFaceQuads(p_getFaceQuads_3_);
}
}
else if (getBlockAt(p_getFaceQuads_2_.down(), p_getFaceQuads_3_, p_getFaceQuads_0_) == Blocks.grass)
{
return modelCubeGrass.getFaceQuads(p_getFaceQuads_3_);
}
}
return p_getFaceQuads_4_;
}
}
else
{
return p_getFaceQuads_4_;
}
}