Java 类net.minecraft.block.BlockIce 实例源码

项目:DynamicSurroundings    文件:FootstepsRegistry.java   
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);
        }
    }
}
项目:ZeldaSwordSkills    文件:ItemDungeonBlock.java   
@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);
    }
}
项目:Fragile-Glass-1.7.10    文件:PatchGen.java   
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;
}