net.minecraft.world.IBlockAccess Java Examples

The following examples show how to use net.minecraft.world.IBlockAccess. 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 File: BlockLinkedHorizontalTexture.java    From AdvancedRocketry with 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
Source File: BlockReactorPart.java    From BigReactors with 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 #3
Source File: BlockEnderFurnace.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 File: BlockLeekCrop.java    From TofuCraftReload with 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 #5
Source File: MetaTileEntityRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #6
Source File: BlockPhasing.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #7
Source File: SmallFireRenderer.java    From GardenCollection with 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 #8
Source File: ModelCertusTank.java    From ExtraCells1 with 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 File: BlockCactus.java    From TFC2 with 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 #10
Source File: SolarGlass.java    From EmergingTechnology with 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 #11
Source File: FWBlock.java    From NOVA-Core with 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 #12
Source File: BlockGardenProxy.java    From GardenCollection with 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 #13
Source File: CTM.java    From Chisel with 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 #14
Source File: BlockWall.java    From customstuff4 with 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 #15
Source File: BlockTraverseLeaves.java    From Traverse-Legacy-1-12-2 with 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 #16
Source File: BlockGardenProxy.java    From GardenCollection with 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 #17
Source File: BlockStorage.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #18
Source File: TileEntityTurbinePowerTap.java    From BigReactors with 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 #19
Source File: BlockLeaves.java    From TFC2 with 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 #20
Source File: RendererPacket.java    From bartworks with 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 #21
Source File: BlockCactus.java    From TFC2 with 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 #22
Source File: BlockGardenProxy.java    From GardenCollection with 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 #23
Source File: BlockMoving.java    From Framez with 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 #24
Source File: HackableMobSpawner.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
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 #25
Source File: PipeBlocking.java    From Logistics-Pipes-2 with MIT License 4 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess worldIn, BlockPos pos, EnumFacing side) {return false;}
 
Example #26
Source File: BlockYubaNoren.java    From TofuCraftReload with MIT License 4 votes vote down vote up
@Override
@Nullable
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
	return NULL_AABB;
}
 
Example #27
Source File: BlockBambooShoot.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
    return BlockFaceShape.UNDEFINED;
}
 
Example #28
Source File: HackableSecurityStation.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canHack(IBlockAccess world, int x, int y, int z, EntityPlayer player){
    TileEntitySecurityStation te = (TileEntitySecurityStation)world.getTileEntity(x, y, z);
    return !te.doesAllowPlayer(player);
}
 
Example #29
Source File: BlockFireboxCasing.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) {
    return state.getValue(ACTIVE) ? 15 : 0;
}
 
Example #30
Source File: BlockCarvableStairs.java    From Chisel-2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
	return carverHelper.getVariation(blockMeta + (metadata / 8));
}