Search in sources :

Example 1 with InfProperty

use of com.infinityraider.infinitylib.block.property.InfProperty in project AgriCraft by AgriCraft.

the class BlockIrrigationChannelAbstract method getStateForPlacement.

@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
    World world = context.getWorld();
    BlockPos pos = context.getPos();
    BlockState state = this.getDefaultState();
    for (Direction dir : Direction.values()) {
        Optional<InfProperty<Boolean>> prop = getConnection(dir);
        if (prop.isPresent()) {
            TileEntity tile = world.getTileEntity(pos.offset(dir));
            if (tile instanceof TileEntityIrrigationComponent) {
                TileEntityIrrigationComponent component = (TileEntityIrrigationComponent) tile;
                if (component.isSameMaterial(context.getItem())) {
                    state = prop.get().apply(state, true);
                }
            }
        }
    }
    return state;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockState(net.minecraft.block.BlockState) InfProperty(com.infinityraider.infinitylib.block.property.InfProperty) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) IWorld(net.minecraft.world.IWorld) Direction(net.minecraft.util.Direction) Nullable(javax.annotation.Nullable)

Aggregations

InfProperty (com.infinityraider.infinitylib.block.property.InfProperty)1 Nullable (javax.annotation.Nullable)1 BlockState (net.minecraft.block.BlockState)1 TileEntity (net.minecraft.tileentity.TileEntity)1 Direction (net.minecraft.util.Direction)1 BlockPos (net.minecraft.util.math.BlockPos)1 IWorld (net.minecraft.world.IWorld)1 World (net.minecraft.world.World)1