Java Code Examples for net.minecraft.world.IBlockAccess

The following examples show how to use net.minecraft.world.IBlockAccess. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: AdvancedRocketry   Source File: BlockLinkedHorizontalTexture.java    License: MIT License 6 votes vote down vote up
@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]);
}
 
Example 2
@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);
    }
}
 
Example 3
@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;
}
 
Example 4
Source Project: BigReactors   Source File: BlockReactorPart.java    License: MIT License 6 votes vote down vote up
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;
}
 
Example 5
@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);
}
 
Example 6
Source Project: TofuCraftReload   Source File: BlockLeekCrop.java    License: MIT License 6 votes vote down vote up
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)));
            }
        }
    }
}
 
Example 7
Source Project: GardenCollection   Source File: BlockGardenProxy.java    License: MIT License 5 votes vote down vote up
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;
}
 
Example 8
Source Project: ExtraCells1   Source File: ModelCertusTank.java    License: MIT License 5 votes vote down vote up
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);

}
 
Example 9
Source Project: EmergingTechnology   Source File: SolarGlass.java    License: MIT License 5 votes vote down vote up
@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);
}
 
Example 10
Source Project: NOVA-Core   Source File: FWBlock.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example 11
Source Project: customstuff4   Source File: BlockWall.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example 12
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;
}
 
Example 13
Source Project: Traverse-Legacy-1-12-2   Source File: BlockTraverseLeaves.java    License: MIT License 5 votes vote down vote up
@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;
}
 
Example 14
Source Project: GardenCollection   Source File: BlockGardenProxy.java    License: MIT License 5 votes vote down vote up
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);
}
 
Example 15
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face)
{
    if (state.getValue(TYPE).isFullCube())
    {
        return BlockFaceShape.SOLID;
    }
    else
    {
        return BlockFaceShape.UNDEFINED;
    }
}
 
Example 16
Source Project: BigReactors   Source File: TileEntityTurbinePowerTap.java    License: MIT License 5 votes vote down vote up
/**
 * 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);
	}
}
 
Example 17
Source Project: TFC2   Source File: BlockLeaves.java    License: GNU General Public License v3.0 5 votes vote down vote up
/*******************************************************************************
 * 2. Rendering 
 *******************************************************************************/

@Override
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos)
{
	return false;
}
 
Example 18
Source Project: bartworks   Source File: RendererPacket.java    License: MIT License 5 votes vote down vote up
@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);
    }
}
 
Example 19
Source Project: TFC2   Source File: BlockCactus.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public IBlockState getPlant(IBlockAccess world, BlockPos pos) 
{
	IBlockState state = world.getBlockState(pos);
	if (state.getBlock() != this) 
		return getDefaultState();
	return state;
}
 
Example 20
Source Project: GardenCollection   Source File: BlockGardenProxy.java    License: MIT License 5 votes vote down vote up
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);
}
 
Example 21
Source Project: Framez   Source File: BlockMoving.java    License: GNU General Public License v3.0 5 votes vote down vote up
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;
    }
 
Example 22
Source Project: GardenCollection   Source File: SmallFireRenderer.java    License: MIT License 5 votes vote down vote up
@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;
}
 
Example 23
Source Project: Chisel   Source File: CTM.java    License: GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 24
Source Project: TFC2   Source File: BlockCactus.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example 25
public void setBlockAccess(IBlockAccess blockAccess) {
    this.blockAccess = blockAccess;
}
 
Example 26
Source Project: TFC2   Source File: BlockSapling.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
{
	return new AxisAlignedBB(0.3, 0, 0.3, 0.7, 0.9, 0.7);
}
 
Example 27
Source Project: AgriCraft   Source File: BlockPeripheral.java    License: MIT License 4 votes vote down vote up
@Override
public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
    return false;
}
 
Example 28
Source Project: Sakura_mod   Source File: BlockMapleSapLog.java    License: MIT License 4 votes vote down vote up
@Override
public int getFlammability(IBlockAccess world, BlockPos pos, EnumFacing face) {
    return 5;
}
 
Example 29
Source Project: GardenCollection   Source File: BlockIvy.java    License: MIT License 4 votes vote down vote up
@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;
}
 
Example 30
Source Project: GardenCollection   Source File: RenderHelperAO.java    License: MIT License 4 votes vote down vote up
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);
}