本文整理汇总了Java中net.minecraft.block.BlockIce类的典型用法代码示例。如果您正苦于以下问题:Java BlockIce类的具体用法?Java BlockIce怎么用?Java BlockIce使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlockIce类属于net.minecraft.block包,在下文中一共展示了BlockIce类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: seedMap
import net.minecraft.block.BlockIce; //导入依赖的package包/类
private void seedMap() {
// Iterate through the blockmap looking for known pattern types.
// Though they probably should all be registered with Forge
// dictionary it's not a requirement.
final Iterator<Block> itr = Block.REGISTRY.iterator();
while (itr.hasNext()) {
final Block block = itr.next();
final String blockName = MCHelper.nameOf(block);
if (block instanceof BlockCrops) {
final BlockCrops crop = (BlockCrops) block;
if (crop.getMaxAge() == 3) {
this.registerBlocks("#beets", blockName);
} else if (blockName.equals("minecraft:wheat")) {
this.registerBlocks("#wheat", blockName);
} else if (crop.getMaxAge() == 7) {
this.registerBlocks("#crop", blockName);
}
} else if (block instanceof BlockSapling) {
this.registerBlocks("#sapling", blockName);
} else if (block instanceof BlockReed) {
this.registerBlocks("#reed", blockName);
} else if (block instanceof BlockFence) {
this.registerBlocks("#fence", blockName);
} else if (block instanceof BlockFlower || block instanceof BlockMushroom) {
this.registerBlocks("NOT_EMITTER", blockName);
} else if (block instanceof BlockLog || block instanceof BlockPlanks) {
this.registerBlocks("wood", blockName);
} else if (block instanceof BlockDoor) {
this.registerBlocks("bluntwood", blockName);
} else if (block instanceof BlockLeaves) {
this.registerBlocks("leaves", blockName);
} else if (block instanceof BlockOre) {
this.registerBlocks("ore", blockName);
} else if (block instanceof BlockIce) {
this.registerBlocks("ice", blockName);
}
}
}
示例2: onItemUse
import net.minecraft.block.BlockIce; //导入依赖的package包/类
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing face, float hitX, float hitY, float hitZ) {
if (player.isSneaking()) {
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
int meta = block.getMetaFromState(state);
if (block instanceof BlockSecretStone) {
block = ((BlockSecretStone.EnumType) state.getValue(BlockSecretStone.VARIANT)).getDroppedBlock();
meta = state.getBlock().getMetaFromState(state);
} else if (block instanceof BlockDungeonStone) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityDungeonStone) {
IBlockState render = ((TileEntityDungeonStone) te).getRenderState();
if (render == null) {
render = ((BlockDungeonStone) block).getDefaultRenderState(stack.getItemDamage() > 7);
}
if (render != null) {
block = render.getBlock();
meta = block.getMetaFromState(render);
}
}
}
if ((block.isOpaqueCube() || block instanceof BlockIce) && Item.getItemFromBlock(block) != null) {
if (world.isRemote) { // Send block's render color to server so held block can render correctly
PacketDispatcher.sendToServer(new HeldBlockColorPacket(block.colorMultiplier(world, pos)));
} else {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
}
stack.getTagCompound().setInteger("renderBlock", Block.getIdFromBlock(block));
stack.getTagCompound().setInteger("metadata", meta);
}
}
return false;
} else {
return super.onItemUse(stack, player, world, pos, face, hitX, hitY, hitZ);
}
}
示例3: genPatch
import net.minecraft.block.BlockIce; //导入依赖的package包/类
private boolean genPatch(Random random, int chunkX, int chunkZ, World world)
{
//Coords of "top left" blocks in chunk
int chunkBlockX = chunkX * 16;
int chunkBlockZ = chunkZ * 16;
//The y coordinate where patch generation will be attempted
int patchY;
//Coords of "top left" blocks in an adjacent chunk
int nextChunkBlockX = chunkBlockX + 16;
int nextChunkBlockZ = chunkBlockZ + 16;
//Check 16 candidate blocks in the chunk to see if they are ice blocks
for(int candX = chunkBlockX; candX < nextChunkBlockX; candX += 8)
{
for(int candZ = chunkBlockZ; candZ < nextChunkBlockZ; candZ += 8)
{
patchY = world.getTopSolidOrLiquidBlock(candX, candZ) - 1;
Block candidate = world.getBlock(candX, patchY, candZ);
if(candidate instanceof BlockIce || FragileGlassBase.iceBlocks.contains(Item.getItemFromBlock(candidate)))
{
int patchRadius = (int) (((2 * random.nextGaussian()) + FragileGlassBase.avePatchSize) / 2);
for (int rad = patchRadius; rad > 0; rad--)
{
for (double d = 0; d < 360; d += 10)
{
double r = Math.toRadians(d);
int nextX = (int) (candX + (rad * Math.cos(r)));
int nextZ = (int) (candZ + (rad * Math.sin(r)));
Block nextBlock = world.getBlock(nextX, patchY, nextZ);
if (nextBlock instanceof BlockIce || FragileGlassBase.iceBlocks.contains(Item.getItemFromBlock(nextBlock)))
{
//Adds a little randomness to the outside of patches, to avoid perfect circles all the time
if (rad > patchRadius - 2)
{
if (random.nextBoolean())
{
world.setBlock(nextX, patchY, nextZ, FragileGlassBase.thinIce);
}
} else {
world.setBlock(nextX, patchY, nextZ, FragileGlassBase.thinIce);
}
}
}
}
world.setBlock(candX, patchY, candZ, FragileGlassBase.thinIce);
//For testing
//System.out.println("Generated patch at ("+candX+", "+patchY+", "+candZ+").");
return true;
}
}
}
return false;
}