类net.minecraft.world.IBlockAccess源码实例Demo

下面列出了怎么用net.minecraft.world.IBlockAccess的API类实例代码及写法,或者点击链接到github查看源代码。

@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world,
		BlockPos pos) {
	
	int offset = 0;

	if(world.getBlockState(pos.add(1,0,0)).getBlock() == this)
		offset |= 0x1;
	if(world.getBlockState(pos.add(0,0,-1)).getBlock() == this)
		offset |= 0x2;
	if(world.getBlockState(pos.add(-1,0,0)).getBlock() == this)
		offset |= 0x4;
	if(world.getBlockState(pos.add(0,0,1)).getBlock() == this)
		offset |= 0x8;
	
	return state.withProperty(TYPE, IconNames.values()[offset]);
}
 
源代码2 项目: GregTech   文件: MetaTileEntityRenderer.java
@Override
public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) {
    MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(world, pos);
    ArrayList<IndexedCuboid6> boundingBox = new ArrayList<>();
    if (metaTileEntity != null) {
        metaTileEntity.addCollisionBoundingBox(boundingBox);
        metaTileEntity.addCoverCollisionBoundingBox(boundingBox);
    }
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.bind(buffer);
    renderState.setPipeline(new Vector3(new Vec3d(pos)).translation(), new IconTransformation(sprite));
    for (Cuboid6 cuboid : boundingBox) {
        BlockRenderer.renderCuboid(renderState, cuboid, 0);
    }
}
 
源代码3 项目: enderutilities   文件: BlockEnderFurnace.java
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos)
{
    state = super.getActualState(state, world, pos);

    TileEntityEnderFurnace te = getTileEntitySafely(world, pos, TileEntityEnderFurnace.class);

    if (te != null)
    {
        EnumMachineMode mode = te.isCookingLast == false ? EnumMachineMode.OFF :
            (te.isBurningLast == false ? EnumMachineMode.ON_NOFUEL : 
                te.fastMode ? EnumMachineMode.ON_FAST : EnumMachineMode.ON_NORMAL);

        state = state.withProperty(MODE, mode);
    }

    return state;
}
 
源代码4 项目: BigReactors   文件: BlockReactorPart.java
private IIcon getAccessPortIcon(IBlockAccess blockAccess, int x, int y,
		int z, int side) {
	TileEntity te = blockAccess.getTileEntity(x, y, z);
	if(te instanceof TileEntityReactorAccessPort) {
		TileEntityReactorAccessPort port = (TileEntityReactorAccessPort)te;

		if(!isReactorAssembled(port) || isOutwardsSide(port, side)) {
			if(port.isInlet()) {
				return _icons[METADATA_ACCESSPORT][PORT_INLET];
			}
			else {
				return _icons[METADATA_ACCESSPORT][PORT_OUTLET];
			}
		}
	}
	return blockIcon;
}
 
源代码5 项目: enderutilities   文件: BlockPhasing.java
@SuppressWarnings("deprecation")
@Override
public boolean shouldSideBeRendered(IBlockState state, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
{
    IBlockState stateAdjacent = blockAccess.getBlockState(pos.offset(side));

    if (state != stateAdjacent)
    {
        return true;
    }
    else if (stateAdjacent.getBlock() == this)
    {
        return false;
    }

    return super.shouldSideBeRendered(state, blockAccess, pos, side);
}
 
源代码6 项目: TofuCraftReload   文件: BlockLeekCrop.java
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
    Random rand = world instanceof World ? ((World) world).rand : RANDOM;

    int age = getAge(state);
    int count = quantityDropped(state, fortune, rand);
    for (int i = 0; i < count; i++) {
        Item item = this.getItemDropped(state, rand, fortune);
        if (item != Items.AIR) {
            drops.add(new ItemStack(item, 1, this.damageDropped(state)));
        }
    }

    if (age >= getMaxAge()) {
        int k = 3 + fortune;
        for (int i = 0; i < k; ++i) {
            if (rand.nextInt(2 * getMaxAge()) <= age) {
                drops.add(new ItemStack(this.getSeed(), 1, this.damageDropped(state)));
            }
        }
    }
}
 
源代码7 项目: GardenCollection   文件: BlockGardenProxy.java
private int getBaseBlockYCoord (IBlockAccess world, int x, int y, int z) {
    if (y == 0)
        return 0;

    Block underBlock = world.getBlock(x, --y, z);
    while (y > 0 && underBlock instanceof IPlantProxy)
        underBlock = world.getBlock(x, --y, z);

    return y;
}
 
源代码8 项目: ExtraCells1   文件: ModelCertusTank.java
public void renderOuterBlock(Block block, int x, int y, int z, RenderBlocks renderer, IBlockAccess world)
{

	Tessellator tessellator = Tessellator.instance;
	boolean tankUp = world.getBlockTileEntity(x, y + 1, z) instanceof TileEntityCertusTank;
	boolean tankDown = world.getBlockTileEntity(x, y - 1, z) instanceof TileEntityCertusTank;
	int meta = 0;
	if (tankUp && tankDown)
		meta = 3;
	else if (tankUp)
		meta = 2;
	else if (tankDown)
		meta = 1;
	if (!tankDown)
	{
		tessellator.setNormal(0.0F, -1F, 0.0F);
		renderer.renderFaceYNeg(block, x, y, z, block.getIcon(0, 0));
	}
	if (!(tankUp))
	{
		tessellator.setNormal(0.0F, 1.0F, 0.0F);
		renderer.renderFaceYPos(block, x, y, z, block.getIcon(1, 0));
	}

	Icon sideIcon = block.getIcon(3, meta);
	tessellator.setNormal(0.0F, 0.0F, -1F);
	renderer.renderFaceZNeg(block, x, y, z, sideIcon);
	tessellator.setNormal(0.0F, 0.0F, 1.0F);
	renderer.renderFaceZPos(block, x, y, z, sideIcon);
	tessellator.setNormal(-1F, 0.0F, 0.0F);
	renderer.renderFaceXNeg(block, x, y, z, sideIcon);
	tessellator.setNormal(1.0F, 0.0F, 0.0F);
	renderer.renderFaceXPos(block, x, y, z, sideIcon);

}
 
源代码9 项目: EmergingTechnology   文件: SolarGlass.java
@SideOnly(Side.CLIENT)
@Override
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos,
        EnumFacing side) {
    IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side));
    Block block = iblockstate.getBlock();

    if (block == this || block == ModBlocks.clearplasticblock) {
        return false;
    }

    return block == this ? false : super.shouldSideBeRendered(blockState, blockAccess, pos, side);
}
 
源代码10 项目: NOVA-Core   文件: FWBlock.java
@Override
public int isProvidingStrongPower(IBlockAccess access, BlockPos pos, IBlockState state, EnumFacing side) {
	Block blockInstance = getBlockInstance(access, VectorConverter.instance().toNova(pos));
	WrapperEvent.StrongRedstone event = new WrapperEvent.StrongRedstone(blockInstance.world(), blockInstance.position(), Direction.fromOrdinal(side.ordinal()));
	Game.events().publish(event);
	return event.power;
}
 
源代码11 项目: customstuff4   文件: BlockWall.java
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
    boolean flag = canWallConnectTo(worldIn, pos, EnumFacing.NORTH);
    boolean flag1 = canWallConnectTo(worldIn, pos, EnumFacing.EAST);
    boolean flag2 = canWallConnectTo(worldIn, pos, EnumFacing.SOUTH);
    boolean flag3 = canWallConnectTo(worldIn, pos, EnumFacing.WEST);
    boolean flag4 = flag && !flag1 && flag2 && !flag3 || !flag && flag1 && !flag2 && flag3;
    return state.withProperty(UP, !flag4 || !worldIn.isAirBlock(pos.up()))
                .withProperty(NORTH, flag)
                .withProperty(EAST, flag1)
                .withProperty(SOUTH, flag2)
                .withProperty(WEST, flag3);
}
 
源代码12 项目: PneumaticCraft   文件: HackableMobSpawner.java
public static boolean isHacked(IBlockAccess world, int x, int y, int z){
    TileEntity te = world.getTileEntity(x, y, z);
    if(te != null) {
        NBTTagCompound tag = new NBTTagCompound();
        te.writeToNBT(tag);
        if(tag.hasKey("RequiredPlayerRange") && tag.getShort("RequiredPlayerRange") == 0) return true;
    }
    return false;
}
 
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
    if (!Minecraft.getMinecraft().gameSettings.fancyGraphics) {
        if (!(blockAccess.getBlockState(pos.offset(side)).getBlock() instanceof BlockLeaves)) {
            return true;
        }
        return false;
    }
    return true;
}
 
源代码14 项目: GardenCollection   文件: BlockGardenProxy.java
public float getPlantOffsetY (IBlockAccess blockAccess, int x, int y, int z, int slot) {
    BlockGarden gardenBlock = getGardenBlock(blockAccess, x, y, z);
    if (gardenBlock == null)
        return 0;

    return gardenBlock.getSlotProfile().getPlantOffsetY(blockAccess, x, getBaseBlockYCoord(blockAccess, x, y, z), z, slot);
}
 
源代码15 项目: enderutilities   文件: BlockStorage.java
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face)
{
    if (state.getValue(TYPE).isFullCube())
    {
        return BlockFaceShape.SOLID;
    }
    else
    {
        return BlockFaceShape.UNDEFINED;
    }
}
 
源代码16 项目: BigReactors   文件: TileEntityTurbinePowerTap.java
/**
 * Check for a world connection, if we're assembled.
 * @param world
 * @param x
 * @param y
 * @param z
 */
protected void checkForConnections(IBlockAccess world, int x, int y, int z) {
	boolean wasConnected = (rfNetwork != null);
	ForgeDirection out = getOutwardsDir();
	if(out == ForgeDirection.UNKNOWN) {
		wasConnected = false;
		rfNetwork = null;
	}
	else {
		// See if our adjacent non-reactor coordinate has a TE
		rfNetwork = null;

		TileEntity te = world.getTileEntity(x + out.offsetX, y + out.offsetY, z + out.offsetZ);
		if(!(te instanceof TileEntityReactorPowerTap)) {
			// Skip power taps, as they implement these APIs and we don't want to shit energy back and forth
			if(te instanceof IEnergyReceiver) {
				IEnergyReceiver handler = (IEnergyReceiver)te;
				if(handler.canConnectEnergy(out.getOpposite())) {
					rfNetwork = handler;
				}
			}
		}
	}
	
	boolean isConnected = (rfNetwork != null);
	if(wasConnected != isConnected && worldObj.isRemote) {
		// Re-render on clients
           worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
	}
}
 
源代码17 项目: TFC2   文件: BlockLeaves.java
/*******************************************************************************
 * 2. Rendering 
 *******************************************************************************/

@Override
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos)
{
	return false;
}
 
源代码18 项目: bartworks   文件: RendererPacket.java
@Override
public void process(IBlockAccess iBlockAccess) {
    if (SideReference.Side.Client) {
        if (this.removal == 0)
            GT_TileEntity_BioVat.staticColorMap.put(this.coords, this.integer);
        else
            GT_TileEntity_BioVat.staticColorMap.remove(this.coords);
    }
}
 
源代码19 项目: TFC2   文件: BlockCactus.java
@Override
public IBlockState getPlant(IBlockAccess world, BlockPos pos) 
{
	IBlockState state = world.getBlockState(pos);
	if (state.getBlock() != this) 
		return getDefaultState();
	return state;
}
 
源代码20 项目: GardenCollection   文件: BlockGardenProxy.java
public float getPlantOffsetX (IBlockAccess blockAccess, int x, int y, int z, int slot) {
    BlockGarden gardenBlock = getGardenBlock(blockAccess, x, y, z);
    if (gardenBlock == null)
        return 0;

    return gardenBlock.getSlotProfile().getPlantOffsetX(blockAccess, x, getBaseBlockYCoord(blockAccess, x, y, z), z, slot);
}
 
源代码21 项目: Framez   文件: BlockMoving.java
private TileMoving get(IBlockAccess w, int x, int y, int z) {

        TileEntity te = w.getTileEntity(x, y, z);
        if (te != null && te instanceof TileMoving)
            return (TileMoving) te;

        return null;
    }
 
源代码22 项目: GardenCollection   文件: SmallFireRenderer.java
@Override
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
    if (block instanceof BlockSmallFire)
        return renderWorldBlock(world, x, y, z, (BlockSmallFire) block, modelId, renderer);

    return false;
}
 
源代码23 项目: Chisel   文件: CTM.java
private static boolean isConnected(IBlockAccess world, int x, int y, int z, int side, Block block, int meta)
{
    int x2 = x, y2 = y, z2 = z;

    switch(side)
    {
        case 0:
            y2--;
            break;
        case 1:
            y2++;
            break;
        case 2:
            z2--;
            break;
        case 3:
            z2++;
            break;
        case 4:
            x2--;
            break;
        case 5:
            x2++;
            break;
    }

    return getBlockOrFacade(world, x, y, z, side).equals(block) && getBlockOrFacadeMetadata(world, x, y, z, side) == meta && (!getBlockOrFacade(world, x2, y2, z2, side).equals(block) || getBlockOrFacadeMetadata(world, x2, y2, z2, side) != meta);
}
 
源代码24 项目: TFC2   文件: BlockCactus.java
@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable)
{
	IBlockState plant = plantable.getPlant(world, pos.offset(direction));
	EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction));

	DesertCactusType veg = (DesertCactusType)state.getValue(META_PROPERTY);
	if(plant.getBlock() == this)
	{

	}
	return false;
}
 
源代码25 项目: seppuku   文件: EventRenderBlockModel.java
public void setBlockAccess(IBlockAccess blockAccess) {
    this.blockAccess = blockAccess;
}
 
源代码26 项目: TFC2   文件: BlockSapling.java
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
{
	return new AxisAlignedBB(0.3, 0, 0.3, 0.7, 0.9, 0.7);
}
 
源代码27 项目: AgriCraft   文件: BlockPeripheral.java
@Override
public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
    return false;
}
 
源代码28 项目: Sakura_mod   文件: BlockMapleSapLog.java
@Override
public int getFlammability(IBlockAccess world, BlockPos pos, EnumFacing face) {
    return 5;
}
 
源代码29 项目: GardenCollection   文件: BlockIvy.java
@Override
public ArrayList<ItemStack> onSheared (ItemStack item, IBlockAccess world, int x, int y, int z, int fortune) {
    ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
    ret.add(new ItemStack(this, 1));
    return ret;
}
 
源代码30 项目: GardenCollection   文件: RenderHelperAO.java
public void setupXPosAOPartial (IBlockAccess blockAccess, Block block, int x, int y, int z, float r, float g, float b) {
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(983055);

    int xGrass = (state.renderMaxX >= 1) ? x + 1 : x;

    boolean blocksGrassXYNP = !blockAccess.getBlock(xGrass, y + 1, z).getCanBlockGrass();
    boolean blocksGrassXYNN = !blockAccess.getBlock(xGrass, y - 1, z).getCanBlockGrass();
    boolean blocksGrassXZNN = !blockAccess.getBlock(xGrass, y, z - 1).getCanBlockGrass();
    boolean blocksGrassXZNP = !blockAccess.getBlock(xGrass, y, z + 1).getCanBlockGrass();

    if (state.renderMaxX < 1)
        setupAOBrightnessXPos(blockAccess, block, x, y, z, blocksGrassXYNP, blocksGrassXYNN, blocksGrassXZNN, blocksGrassXZNP);

    setupAOBrightnessXNeg(blockAccess, block, x + 1, y, z, blocksGrassXYNP, blocksGrassXYNN, blocksGrassXZNN, blocksGrassXZNP);

    float xClamp = MathHelper.clamp_float((float) state.renderMaxX, 0, 1);
    mixAOBrightnessLightValueX(xClamp, 1 - xClamp);

    int blockBrightness = block.getMixedBrightnessForBlock(blockAccess, x, y, z);
    if (state.renderMaxX >= 1.0D || !blockAccess.getBlock(x + 1, y, z).isOpaqueCube())
        blockBrightness = block.getMixedBrightnessForBlock(blockAccess, x + 1, y, z);

    float aoOpposingBlock = blockAccess.getBlock(x + 1, y, z).getAmbientOcclusionLightValue();
    float aoXYZPNP = (aoLightValueScratchXYIN + aoLightValueScratchXYZINP + aoOpposingBlock + aoLightValueScratchXZIP) / 4.0F;
    float aoXYZPNN = (aoLightValueScratchXYZINN + aoLightValueScratchXYIN + aoLightValueScratchXZIN + aoOpposingBlock) / 4.0F;
    float aoXYZPPN = (aoLightValueScratchXZIN + aoOpposingBlock + aoLightValueScratchXYZIPN + aoLightValueScratchXYIP) / 4.0F;
    float aoXYZPPP = (aoOpposingBlock + aoLightValueScratchXZIP + aoLightValueScratchXYIP + aoLightValueScratchXYZIPP) / 4.0F;

    float aoTL = (float)((double)aoXYZPNP * (1.0D - state.renderMinY) * state.renderMaxZ + (double)aoXYZPNN * (1.0D - state.renderMinY) * (1.0D - state.renderMaxZ) + (double)aoXYZPPN * state.renderMinY * (1.0D - state.renderMaxZ) + (double)aoXYZPPP * state.renderMinY * state.renderMaxZ);
    float aoBL = (float)((double)aoXYZPNP * (1.0D - state.renderMinY) * state.renderMinZ + (double)aoXYZPNN * (1.0D - state.renderMinY) * (1.0D - state.renderMinZ) + (double)aoXYZPPN * state.renderMinY * (1.0D - state.renderMinZ) + (double)aoXYZPPP * state.renderMinY * state.renderMinZ);
    float aoBR = (float)((double)aoXYZPNP * (1.0D - state.renderMaxY) * state.renderMinZ + (double)aoXYZPNN * (1.0D - state.renderMaxY) * (1.0D - state.renderMinZ) + (double)aoXYZPPN * state.renderMaxY * (1.0D - state.renderMinZ) + (double)aoXYZPPP * state.renderMaxY * state.renderMinZ);
    float aoTR = (float)((double)aoXYZPNP * (1.0D - state.renderMaxY) * state.renderMaxZ + (double)aoXYZPNN * (1.0D - state.renderMaxY) * (1.0D - state.renderMaxZ) + (double)aoXYZPPN * state.renderMaxY * (1.0D - state.renderMaxZ) + (double)aoXYZPPP * state.renderMaxY * state.renderMaxZ);

    int brXYZPNP = getAOBrightness(aoBrightnessXYIN, aoBrightnessXYZINP, aoBrightnessXZIP, blockBrightness);
    int brXYZPNN = getAOBrightness(aoBrightnessXZIP, aoBrightnessXYIP, aoBrightnessXYZIPP, blockBrightness);
    int brXYZPPN = getAOBrightness(aoBrightnessXZIN, aoBrightnessXYZIPN, aoBrightnessXYIP, blockBrightness);
    int brXYZPPP = getAOBrightness(aoBrightnessXYZINN, aoBrightnessXYIN, aoBrightnessXZIN, blockBrightness);

    state.brightnessTopLeft = mixAOBrightness(brXYZPNP, brXYZPPP, brXYZPPN, brXYZPNN, (1.0D - state.renderMinY) * state.renderMaxZ, (1.0D - state.renderMinY) * (1.0D - state.renderMaxZ), state.renderMinY * (1.0D - state.renderMaxZ), state.renderMinY * state.renderMaxZ);
    state.brightnessBottomLeft = mixAOBrightness(brXYZPNP, brXYZPPP, brXYZPPN, brXYZPNN, (1.0D - state.renderMinY) * state.renderMinZ, (1.0D - state.renderMinY) * (1.0D - state.renderMinZ), state.renderMinY * (1.0D - state.renderMinZ), state.renderMinY * state.renderMinZ);
    state.brightnessBottomRight = mixAOBrightness(brXYZPNP, brXYZPPP, brXYZPPN, brXYZPNN, (1.0D - state.renderMaxY) * state.renderMinZ, (1.0D - state.renderMaxY) * (1.0D - state.renderMinZ), state.renderMaxY * (1.0D - state.renderMinZ), state.renderMaxY * state.renderMinZ);
    state.brightnessTopRight = mixAOBrightness(brXYZPNP, brXYZPPP, brXYZPPN, brXYZPNN, (1.0D - state.renderMaxY) * state.renderMaxZ, (1.0D - state.renderMaxY) * (1.0D - state.renderMaxZ), state.renderMaxY * (1.0D - state.renderMaxZ), state.renderMaxY * state.renderMaxZ);

    state.setColor(r * state.colorMultXPos, g * state.colorMultXPos, b * state.colorMultXPos);
    state.scaleColor(state.colorTopLeft, aoTL);
    state.scaleColor(state.colorBottomLeft, aoBL);
    state.scaleColor(state.colorBottomRight, aoBR);
    state.scaleColor(state.colorTopRight, aoTR);
}
 
 类所在包
 类方法
 同包方法